spring Sping Boot 测试默认配置警告“参数'systemProperties'已弃用”是什么?

5t7ly7z5  于 12个月前  发布在  Spring
关注(0)|答案(1)|浏览(374)

在Sping 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


我做错什么了吗?

disbfnqx

disbfnqx1#

这与Spring Boot 无关。
您分享的警告来自Maven Surefire,它告诉您在pom.xml中使用<systemPropertyVariables>而不是<systemProperties>
详情请参见Surefire's documentation

相关问题