jdbcType使用错误导致mapper注入失败,导致项目启动失败

博主分享了项目中遇到的MyBatis构建错误,原因在于将DATETIME误设为jdbcType,导致类型匹配失败。文章详细介绍了JavaType和JDBCType的关系,并提醒开发者注意MyBatis支持的内置类型。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

项目突然起不来..

Cause: org.apache.ibatis.builder.BuilderException: Error resolving JdbcType. Cause: java.lang.IllegalArgumentException: 
No enum constant org.apache.ibatis.type.JdbcType.DATETIME

怀疑包扫描路径扫描配置错误..

怀疑mapper注解错误..

怀疑mapper编写路径问题..

看了将近一个小时,才发现是因为jdbcType编写错误的问题,

小伙伴写了一个类型:DATETIME

然而,MyBatis所支持的jdbcType类型只有以下几种:

BIT、 FLOAT、CHAR、TIMESTAMP、OTHER、 UNDEFINED
TINYINT、REAL、VARCHAR、BINARY、BLOB、 NVARCHAR
SMALLINT、DOUBLE、LONGVARCHAR、VARBINARY、CLOB、NCHAR
INTEGER、NUMERIC、DATE、 LONGVARBINARY、BOOLEAN 、NCLOB
BIGINT、DECIMAL、TIME、NULL、CURSOR

嗯嗯..因为myBatis枚举不出 DATETIME,所以报错了..没毛病,Java它再次证明我是愚蠢的..

那么,下面总结一下 Mybatis中javaType和jdbcType关系对照表

JDBC Type           Java Type  
CHAR                String  
VARCHAR             String  
LONGVARCHAR         String  
NUMERIC             java.math.BigDecimal  
DECIMAL             java.math.BigDecimal  
BIT             boolean  
BOOLEAN             boolean  
TINYINT             byte  
SMALLINT            short  
INTEGER             int  
BIGINT              long  
REAL                float  
FLOAT               double  
DOUBLE              double  
BINARY              byte[]  
VARBINARY           byte[]  
LONGVARBINARY               byte[]  
DATE                java.sql.Date  
TIME                java.sql.Time  
TIMESTAMP           java.sql.Timestamp  
CLOB                Clob  
BLOB                Blob  
ARRAY               Array  
DISTINCT            mapping of underlying type  
STRUCT              Struct  
REF                         Ref  
DATALINK            java.net.URL[color=red][/color] 
启动springboot项目报错:2025-07-30 10:48:55.654 ERROR 50120 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sysDirController' defined in file [D:\0728\lowcode_api\target\classes\org\sunwoda\lowCode\api\system\SysDirController.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'lpDirServiceImpl' defined in file [D:\0728\lowcode_service_impl\target\classes\org\sunwoda\lowCode\service\impl\system\impl\LpDirServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'lpDirMapper' defined in file [D:\0728\lowcode_service_impl\target\classes\org\sunwoda\lowCode\service\impl\system\mapper\LpDirMapper.class]: Unsatisfied dependency expressed through bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [com/baomidou/mybatisplus/autoconfigure/MybatisPlusAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.apache.ibatis.session.SqlSessionFactory]: Factory method 'sqlSessionFactory' threw exception; nested exception is java.io.IOException: Failed to parse mapping resource: 'file [D:\0728\lowcode_service_impl\target\classes\mapper\system\LpAppAdminDirMapper.xml]'
最新发布
07-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值