Cannot find class: NUMERIC

本文解决MyBatis中使用NUMERIC作为resultType导致的ClassNotFound异常问题,通过将resultType修改为java.math.BigDecimal实现正确映射,并提供SQL数据类型与Java数据类型之间的转换对照表。

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

mybatis启动报错:

org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'cn/xdf/yn/api/mapper/ExamQuestionMapper.xml'. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'NUMERIC'.  Cause: java.lang.ClassNotFoundException: Cannot find class: NUMERIC

 

 

	<select id="sumSorceByTestIdAndSubjectIdAndAttrIdB" resultType="NUMERIC">
		select sum(a.score) from exam_question a,exam_test_detail b,que_attr_busi c 
		where a.pap_Id =b.pap_Id and a.que_Id=c.busi_Id and a.subject_Id=#{subjectId} and 
		b.parent_Test_Id=#{testId} and c.attr_Id=#{attrId}
	</select>

resultType改为

resultType="java.math.BigDecimal"

 

SQL数据类型和Java数据类型的对应关系

integer、int ---> int

tinyint、smallint ---> short

bigint ---> long

decimal、numeric ---> java.math.BigDecimal

float ---> float

double ---> double

char、varchar ---> String

boolean、bit ---> boolean

date ---> java.sql.Date

time ---> java.sql.Time

timestamp ---> java.sql.Timestamp

blob ---> java.sql.Blob

clob ---> java.sql.Clob

array ---> java.sql.Array

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值