I'm trying to accomplish when the team sets the websphere profile active that the cloud profile is also activated.
yaml file
---
spring:
application:
name: kicapp
output:
ansi:
enabled: ALWAYS
profiles:
active: local
#server:
#context-path: /
#port: 8080
#logging:
#level:
#org.springframework.security: DEBUG
---
spring:
profiles: local
---
spring:
profiles: unittest
---
spring:
profiles: cloud
test: loaded
---
spring:
profiles: websphere
include: cloud
When I set --spring.profiles.active=websphere
I receive the following error
Caused by: mapping values are not allowed here in 'reader', line 28, column 12: include: cloud
This appears to be a restriction with the SnakeYAML
parser and the way Spring Boot uses it. Since yaml allows multiple distinct documents to be specified in a single file with a ---
separator, the way Spring separates out separate documents is by the spring.profiles
key, this key is expected to be a simple structure and not a complex structure unfortunately.
A good workaround is actually to split this into multiple files this way:
application.yaml
with common content,
application-<profile>
with profile specific extensions, with this structure in place key spring.profiles.include
will work as expected.
Following Biju's answer, if you want to keep the single file with ---
separator and not use separate profile files, you can define the spring.profiles.include
key as follows :
---
spring:
profiles: currentProfile
profiles.include: profileToInclude
That way it's not a complex structure to parse and both keys exist.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With