什么是正确的注释,因为 @SpringApplicationConfiguration、@WebIntegration 在 Spring Boot 框架中已被弃用? [英] What is the proper annotation since @SpringApplicationConfiguration, @WebIntegration, is deprecated in Spring Boot Framework?

查看:30
本文介绍了什么是正确的注释,因为 @SpringApplicationConfiguration、@WebIntegration 在 Spring Boot 框架中已被弃用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

@SpringApplicationConfiguration@WebIntegration 自 Spring Boot Framework 1.4 起已被弃用,因此正确的注释是什么?我正在尝试进行单元测试.

解决方案

查看已弃用类的 JavaDocs:

* @deprecated 自 1.4 起支持* {@link org.springframework.boot.test.context.SpringBootTest} 与* {@code webEnvironment=RANDOM_PORT} 或 {@code webEnvironment=DEFINED_PORT}.*/...@已弃用公共@interface WebIntegrationTest {

<小时>

* @deprecated 自 1.4 起支持 {@link SpringBootTest} 或直接使用* {@link SpringBootContextLoader}.*/...@已弃用公共@interface SpringApplicationConfiguration {

<块引用>

TestRestTemplate() 是否也有替代品?

是的,在这里:

 * @deprecated 自 1.4 起支持* {@link org.springframework.boot.test.web.client.TestRestTemplate}*/@已弃用公共类 TestRestTemplate 扩展 RestTemplate {

What is the proper annotation since @SpringApplicationConfiguration and @WebIntegration are deprecated as of Spring Boot Framework 1.4? I'm trying to play around with unit testing.

解决方案

Take a look into JavaDocs of deprecated classes:

* @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}.
 */
...
@Deprecated
public @interface WebIntegrationTest {


* @deprecated as of 1.4 in favor of {@link SpringBootTest} or direct use of
* {@link SpringBootContextLoader}.
*/
...
@Deprecated
public @interface SpringApplicationConfiguration {

Is there also a replacement for TestRestTemplate()?

Yes, here it is:

 * @deprecated as of 1.4 in favor of
 * {@link org.springframework.boot.test.web.client.TestRestTemplate}
 */
@Deprecated
public class TestRestTemplate extends RestTemplate {

这篇关于什么是正确的注释,因为 @SpringApplicationConfiguration、@WebIntegration 在 Spring Boot 框架中已被弃用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆