因为我没有指定编译的jdk版本,重新import项目后老是提示
Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.mybatis.spring.mapper.MapperScannerConfigurer#0' defined
因为我确定项目代码上是没问题的,所以唯一的可能就是编译上出错,也就是配置又问题,上网找了好久才解决
1. 在pom中加入如下编译版本
2. web.xml改为3.0
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0">
<!-- 指定maven编译方式为jdk1.7版本 -->
<profiles>
<profile>
<id>jdk-1.7</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.7</jdk>
</activation>
<properties>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
</properties>
</profile>
</profiles>
本文详细记录了解决Spring项目中出现的ContextInitializationFailed错误的过程,主要原因是未指定正确的JDK版本导致。通过修改pom.xml文件中的Maven编译配置和更新web.xml到3.0版本,成功解决了MyBatis配置Bean创建异常的问题。
1186

被折叠的 条评论
为什么被折叠?



