解决Failed to load ApplicationContext问题的思路

中文翻译:

  • 加载ApplicationContext失败

第一步:首先检查测试类的注解 以及 依赖

@SpringBootTest
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

第二步:检查包名是否正确

检查xml文件中的包名或者包的路径是否正确,因为是通过xml来配置bean,对于无法加载,一般情况下都是从将其注入到容器中的xml文件入手。

 第三步:检查编码格式

idea的话左上角点开file=>setting 搜索file encoding即可出来选择

 第四步:检查jdk版本

找到项目结构 左上角file=>project structure

 

总结:这种问题出现后优先检查maven和xml文件就好

如果您有更好的方式愿意分享 请您留言告知哈 谢谢

猜你喜欢

转载自blog.csdn.net/lps12345666/article/details/130115314