Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'BaseResultMap'

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'administratorParkMapper' defined in file [F:\SSM-PARKSERVICES\PARK-SERVICE\target\PARK-SERVICE\WEB-INF\classes\com\zrkj\dao\AdministratorParkMapper.class]: Cannot resolve reference to bean 'sqlSessionFactory' while setting bean property 'sqlSessionFactory'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml]: Invocation of init method failed; nested exception is org.springframework.core.NestedIOException: Failed to parse mapping resource: 'file [F:\SSM-PARKSERVICES\PARK-SERVICE\target\PARK-SERVICE\WEB-INF\classes\mappers\ParkMapper.xml]'; nested exception is org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. Cause: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias 'BaseResultMap'.  Cause: java.lang.ClassNotFoundException: Cannot find class: BaseResultMap

Caused by: java.lang.ClassNotFoundException: Cannot find class: BaseResultMap
	at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:200)
	at org.apache.ibatis.io.ClassLoaderWrapper.classForName(ClassLoaderWrapper.java:89)
	at org.apache.ibatis.io.Resources.classForName(Resources.java:261)
	at org.apache.ibatis.type.TypeAliasRegistry.resolveAlias(TypeAliasRegistry.java:116)
	... 95 more

看到第一个Caused by 的时候,一眼看到了“administratorParkMapper”这个类。我一心以为是这个类里写错了,找半天找不到错在哪了,后面百度,找到了这个大兄弟的回答Caused by: org.apache.ibatis.type.TypeException: Could not resolve type alias 'BaseResultMap',我仔细看了看administratorParkMapper.xml结果也没错啊,后面注释了,还是报这个错。。

结果第一个Caused by 后面还有句“Failed to parse mapping resource: 'file [F:\SSM-PARKSERVICES\PARK-SERVICE\target\PARK-SERVICE\WEB-INF\classes\mappers\ParkMapper.xml]';”,我在才去parkMapper.xml中去看,原来之前改了个需求,我就我改了sql,结果没改正确。。

原本:

<select id="selectNameByArea" parameterType="java.lang.String" resultType="String">
     select P_NAME from PARK where P_AREA=#{area} and P_STATUS=1
</select>

改之后报错:

<select id="selectNameByArea" parameterType="java.lang.String" resultType="BaseResultMap">
    select ID,P_NAME from PARK where P_AREA=#{area} and P_STATUS=1
</select>

报错就是这个返回类型的问题,纠正:

<select id="selectNameByArea" parameterType="java.lang.String" resultMap="BaseResultMap">
    select ID,P_NAME from PARK where P_AREA=#{area} and P_STATUS=1
</select>

猜你喜欢

转载自blog.csdn.net/qq_40594137/article/details/81484944