问题:
in my project i have starter and spring-boot application with this starter.
Starter contains application.yaml file with few properties. For example:
my:
test:
val...
可以将文章内容翻译成中文,广告屏蔽插件会导致该功能失效:
问题:
in my project i have starter and spring-boot application with this starter.
Starter contains application.yaml file with few properties. For example:
my:
test:
value: test
spring:
profiles:
active: development
i'm adding application.yaml file to my spring-boot app, and values from starter's yaml aren't injected to context. My question, how i can configure 2 yaml files in starter and application with option for override values with spring-boot app's starter, for example:
spring:
profiles:
active: testing
After merge i want to have:
spring.profiles.active=testing
my.test.value=test
Currently it's failed with error: Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'my.test.value' in value "${my.test.value}"
回答1:
Use spring.profiles.include
spring:
profiles:
active: testing
include: default
Or you can create different application-profile.yml
(for example application-testing.yml) and specify the profile while starting spring boot application
Command
java -jar name.jar spring.profiles.active=testing // it will pick the properties values from application-testing.yml
In the yml file use include to include any other profiles
application-testing.yml
spring:
profiles:
include: default
回答2:
@Deadpool One issue with override I made application-starter.yaml in starter and include it in sprinng-boot with include.
my:
test:
value: spring--123
spring:
profiles:
active: development
include: starter
I injected with @Value
@Value("${my.test.value}")
private String testval;
and testval=test (from starter) Have i option for make values from application.yaml more primary?
thanks