小编Ton*_*lla的帖子

@TestPropertySource 会尊重 SPEL 或其他属性的值吗?

我想知道是否@TestPropertySource会尊重 SpEL 或者至少允许一个属性替换另一个属性的值。

这是一个与动态属性 @TestPropertySource类似的问题

假设我所指的属性存在于属性中的文件之一中locations......

例如,如果我想做类似的事情:

@TestPropertySource(
    locations = {"classpath:application.properties", "classpath:database.properties"},
    properties = {"newPortNum = #{1 + Integer.parseInt(${myapp.web.server.port.ssl})}})
Run Code Online (Sandbox Code Playgroud)

或这个:

@TestPropertySource(
    locations = {"classpath:application.properties", "classpath:database.properties"},
    properties = {"outputFile = ${outputDir}/foo.txt"})
Run Code Online (Sandbox Code Playgroud)

我需要实施 aTestExecutionListener@BootstrapWith来完成此任务吗?

spring spring-test spring-boot

6
推荐指数
1
解决办法
986
查看次数

标签 统计

spring ×1

spring-boot ×1

spring-test ×1