[英]java.lang.IllegalStateException: Failed to load ApplicationContext: snakeyaml dependency issue
Due to snakeyaml vulnerability, I am trying to exclude it in spring-boot-starter-web using exclusions由于 snakeyaml 漏洞,我试图使用排除在 spring-boot-starter-web 中排除它
dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</exclusion>
</exclusions>
</dependency>
I have a testcase which uses @ContextConfiguration tag from springboot我有一个使用来自 springboot 的 @ContextConfiguration 标签的测试用例
@SpringBootTest
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = MongoConfig.class)
public class MongoConfigTest {
MongoConfig classUnderTest = new MongoConfig(); ...
This testcase is failing due to below error:由于以下错误,此测试用例失败:
<error message="Failed to load ApplicationContext"
type="java.lang.IllegalStateException">java.lang.IllegalStateException: Failed to load
ApplicationContext
Caused by: java.lang.IllegalStateException: Attempted to load Config resource 'class path
resource [application.yml]' via location 'optional:classpath:/' but snakeyaml was not
found on the classpath
</error>
How to resolve this issue?如何解决这个问题?
Spring-Boot version: 2.5.13
java: 11
I removed these three tags which was responsible for loading the application context我删除了这三个负责加载应用程序上下文的标签
@SpringBootTest
@RunWith(SpringRunner.class)
@ContextConfiguration(classes = MongoConfig.class)
This worked for me.这对我有用。 Is there any better way to tackle this issue?
有没有更好的方法来解决这个问题?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.