Error creating bean with name 'sqlSessionFactory' defined in class path resource [spring-mybatis.xml

Error creating bean with name ‘sqlSessionFactory’ defined in class path resource [spring-mybatis.xml

Caused by: org.apache.ibatis.builder.BuilderException: Error resolving class. Cause: org.apache.ibatis.type.TypeException: Could not resolve type alias ‘com.xs.vote.domain.User’. Cause: java.lang.ClassNotFoundException: Cannot find class: com.xs.vote.domain.User
下午在配置SSM时出现的这个错:
查询了很多原因之后找到了问题的根源:

    <property name="dataSource" ref="dataSource" />
    <!-- 自动扫描mapping.xml文件 -->
        <property name="mapperLocations" value="classpath:com/xs/vote/mapping/*.xml"></property>
    </bean>

而我的所有配置文件是在src同级目录config下面,看到这里想必你已经知道了错误的原因。映射文件路径的问题如果写classpath:com/xs/vote/mapping/.xml是表示在扫描的src下面的,这时需要更改classpath的扫描路径 ,改为:classpath:config/com/xs/vote/mapping/*.xml

    <property name="dataSource" ref="dataSource" />
    <!-- 自动扫描mapping.xml文件 -->
    <property name="mapperLocations" value="classpath*:config/com/xs/vote/mapping/*.xml"></property>
</bean>

然后解决了问题,不同的问题需要不同的解决办法,希望对你有帮助!

猜你喜欢

转载自blog.csdn.net/m0_37852553/article/details/79705752