解决:Failed to load ApplicationContext

解决:Failed to load ApplicationContext

一般按照如下步骤即可解决

第一步:检查注解

检查是否有如下注解

@RunWith(SpringRunner.class)
@SpringBootTest

如果没有,添加依赖并补充注解

<dependency>
	<groupId>junit</groupId>
	<artifactId>junit</artifactId>
	<version>4.13</version>
	<scope>test</scope>
</dependency>

第二步:检查包名

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

示例:

在这里插入图片描述

第三步:检查编码格式

setting

在这里插入图片描述

application.yml

在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/weixin_44829930/article/details/109323453