Spring Boot 测试默认配置警告“Parameter 'systemProperties' is deprecated”是什么意思?

问题描述 投票:0回答:1

在Spring Boot测试中,当我用@SpringBootTest注解时, 我收到警告:

Parameter 'systemProperties' is deprecated: Use systemPropertyVariables instead.

这是为什么?我该如何解决?

如果我使用

systemProperties
变量,这个错误可能是公平的。 例如:

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"key1=value1", "key2=value2"}, systemProperties = {"sysKey1=sysValue1", "sysKey2=sysValue2"})

然后我也许可以通过类似的方法来修复它

@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {"key1=value1", "key2=value2"}, systemPropertyVariables = {"sysKey1=sysValue1", "sysKey2=sysValue2"})

以下是我使用的 Spring 版本:

mvn dependency:tree | grep spring
[INFO] +- org.springframework.shell:spring-shell-starter:jar:3.1.5:compile
[INFO] |  +- org.springframework.shell:spring-shell-autoconfigure:jar:3.1.5:compile
[INFO] |  |  \- org.springframework.boot:spring-boot-autoconfigure:jar:3.1.5:compile
[INFO] |  +- org.springframework.shell:spring-shell-core:jar:3.1.5:compile
[INFO] |  |  +- org.springframework.boot:spring-boot-starter-validation:jar:3.1.5:compile
[INFO] |  |  +- org.springframework:spring-messaging:jar:6.0.13:compile
[INFO] |  |  |  \- org.springframework:spring-beans:jar:6.0.13:compile
[INFO] |  +- org.springframework.shell:spring-shell-standard:jar:3.1.5:compile
[INFO] |  +- org.springframework.shell:spring-shell-standard-commands:jar:3.1.5:compile
[INFO] |  +- org.springframework.shell:spring-shell-table:jar:3.1.5:compile
[INFO] |  |  \- org.springframework:spring-context:jar:6.0.13:compile
[INFO] |  |     +- org.springframework:spring-aop:jar:6.0.13:compile
[INFO] |  |     \- org.springframework:spring-expression:jar:6.0.13:compile
[INFO] |  \- org.springframework.boot:spring-boot-starter:jar:3.1.5:compile
[INFO] |     +- org.springframework.boot:spring-boot:jar:3.1.5:compile
[INFO] |     +- org.springframework.boot:spring-boot-starter-logging:jar:3.1.5:compile
[INFO] \- org.springframework.boot:spring-boot-starter-test:jar:3.1.5:test
[INFO]    +- org.springframework.boot:spring-boot-test:jar:3.1.5:test
[INFO]    +- org.springframework.boot:spring-boot-test-autoconfigure:jar:3.1.5:test
[INFO]    +- org.springframework:spring-core:jar:6.0.13:compile
[INFO]    |  \- org.springframework:spring-jcl:jar:6.0.13:compile
[INFO]    +- org.springframework:spring-test:jar:6.0.13:test

我在这里做错了什么吗?

spring spring-boot spring-test spring-bean spring-shell
1个回答
0
投票

这与 Spring Boot 无关。

您分享的警告来自 Maven Surefire,它告诉您在

<systemPropertyVariables>
中使用
<systemProperties>
而不是
pom.xml

有关详细信息,请参阅Surefire 的文档

© www.soinside.com 2019 - 2024. All rights reserved.