我的SpringBootTest annotation无法解析为类型。这里也有同样的问题,但似乎添加依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<version>2.0.5.RELEASE</version>
<scope>test</scope>
</dependency>
字符串
整个问题是我想使用@ContextConfiguration,但它已被弃用,建议使用@SpringBootTest(classes = MyMainClass.class)
5条答案
按热度按时间hof1towb1#
删除
<scope>
后,我能够解决我的问题字符串
1rhkuytd2#
尝试使用依赖2.0.3。我现在使用这个版本。
字符串
z6psavjg3#
如果使用父启动器,则不需要在测试依赖项中定义版本,这可能会在加载时发生冲突。
字符串
所以完整的pom应该是这样的。
型
omvjsjqw4#
我会尝试在Spring Test class中使用@RunWith annotation和@Test,这里有一个例子:
字符串
我希望它能解决这个问题
uoifb46i5#
感谢@kj007。如果有人在“gradle”上搜索答案,那么这行可能适合你:
字符串
“It worked on my Computer”(在我的电脑上运行)