哪个版本的spring boot包含了@WebIntegrationTest,添加时在Intellij中显示为红色
Which version of spring boot has @WebIntegrationTest included, it shows red in Intellij at the time of adding it
我在 Gradle 文件中添加了 Spring 引导测试依赖项作为
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
ext['mockito.version'] = '2.7.5'
仍然无法使用 @WebIntegrationTest
,如果我尝试在 Intellij 中添加,它会显示红色。我应该在我的应用程序中包含什么,以便我能够使用 @WebIntegrationTest
?
测试 REST API
我可以用不同的方法对其进行测试,但无法理解它失败的原因
来自
org.springframework.boot.test.WebIntegrationTest
javadoc(强调我的)
This annotation can be used as an alternative to @IntegrationTest and @WebAppConfiguration.
Since:1.2.1
Still not able to use @WebIntegrationTest, it shows red color if I try
to add in intellij.
正如您所说,您拥有 springboot 1.5.1 版本,WebIntegrationTest
class 从 1.4 开始被弃用,取而代之的是 SpringBootTest
。
下面是上面支持的javadocs。
- @since 1.2.1 * @see IntegrationTest * @deprecated as of 1.4 in favor of * {@link
org.springframework.boot.test.context.SpringBootTest} with * {@code
webEnvironment=RANDOM_PORT} or {@code webEnvironment=DEFINED_PORT}.
*/ @Documented @Inherited @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE)
@BootstrapWith(WebAppIntegrationTestContextBootstrapper.class)
@Deprecated public @interface WebIntegrationTest {
这里有两个选择,
- 放弃
WebIntegrationTest
class 并开始使用 SpringBootTest
- 将springboot版本降到1.4.0以下使用
WebIntegrationTest
(不推荐)
这是 1.4.0-M2 发行说明的 link,解释了 WebIntegrationTest
的弃用
希望对您有所帮助!
这些已弃用的注释
@SpringApplicationConfiguration(classes = arrayOf(BootApplication::class))
@WebIntegrationTest("server.port=8081")
在 Spring Boot 1.5+ 等同于
@SpringBootTest(classes = arrayOf(BootApplication::class), properties = arrayOf("server.port=8081"))
@WebAppConfiguration
我在 Gradle 文件中添加了 Spring 引导测试依赖项作为
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test'
ext['mockito.version'] = '2.7.5'
仍然无法使用 @WebIntegrationTest
,如果我尝试在 Intellij 中添加,它会显示红色。我应该在我的应用程序中包含什么,以便我能够使用 @WebIntegrationTest
?
我可以用不同的方法对其进行测试,但无法理解它失败的原因
来自
org.springframework.boot.test.WebIntegrationTest
javadoc(强调我的)
This annotation can be used as an alternative to @IntegrationTest and @WebAppConfiguration. Since:1.2.1
Still not able to use @WebIntegrationTest, it shows red color if I try to add in intellij.
正如您所说,您拥有 springboot 1.5.1 版本,WebIntegrationTest
class 从 1.4 开始被弃用,取而代之的是 SpringBootTest
。
下面是上面支持的javadocs。
- @since 1.2.1 * @see IntegrationTest * @deprecated as of 1.4 in favor of * {@link org.springframework.boot.test.context.SpringBootTest} with * {@code webEnvironment=RANDOM_PORT} or {@code webEnvironment=DEFINED_PORT}. */ @Documented @Inherited @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @BootstrapWith(WebAppIntegrationTestContextBootstrapper.class) @Deprecated public @interface WebIntegrationTest {
这里有两个选择,
- 放弃
WebIntegrationTest
class 并开始使用SpringBootTest
- 将springboot版本降到1.4.0以下使用
WebIntegrationTest
(不推荐)
这是 1.4.0-M2 发行说明的 link,解释了 WebIntegrationTest
希望对您有所帮助!
这些已弃用的注释
@SpringApplicationConfiguration(classes = arrayOf(BootApplication::class))
@WebIntegrationTest("server.port=8081")
在 Spring Boot 1.5+ 等同于
@SpringBootTest(classes = arrayOf(BootApplication::class), properties = arrayOf("server.port=8081"))
@WebAppConfiguration