欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘VARVHAR‘

程序员文章站 2024-01-20 16:26:34
事件:在mapper.xml里面自己手动添加了个area_code的字段,而不是复制的已经写好的映射,加入了映射之后报错信息如下:Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'VARVHAR'. Cause: java.lang.ClassNotFoun...

事件:

在mapper.xml里面自己手动添加了个area_code的字段,而不是复制的已经写好的映射,加入了映射之后报错信息如下:

Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'VARVHAR'.  Cause: java.lang.ClassNotFoundException: Cannot find class: VARVHAR
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:589)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503)
	at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
	at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
	at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)
	at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
	at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
	at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
	at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1255)
	at org.springframework.boot.SpringApplication.run(SpringApplication.java:1243)
	at com.jobtbao.JobtbaoPlatformApplication.main(JobtbaoPlatformApplication.java:18)

加入的映射如下:

<result column="area_code" javaType="VARCHAR" property="areaCode"/>

聪明的你能看出我的问题出在哪里吗?[斜眼 --_-- ]

看不出也没关系,下面我就娓娓道来~~~~

解决过程

我将这句映射注释掉就不报错了,所以肯定我是我的这句映射的问题,仔细看了几遍,其实并没有仔细对,因为我只看了属性值,属性并没有检查,于是查了一下,看到了这篇文章,感谢大神的前车之鉴!
一看我的也是这个问题,我赶紧将javaType="VARCHAR" 改为 jdbcType="VARCHAR"即可,即:

<result column="area_code" jdbcType="VARCHAR" property="areaCode"/>

也就是说我把jdbcType写成了javaType,这两个属性值的区别和用途很明显,也算是一个教训吧。

与君共勉!!!

本文地址:https://blog.csdn.net/fhf2424045058/article/details/107353841