When I try to build the application via Maven mvn install
, it says
java.lang.IllegalArgumentException: Could not resolve placeholder 'example_token' in value "${example_token}"
I assume it happens because the example_token
does not exist in application.yml
, it is both in application-dev.yml
and application-prod.yml
though.
The idea is to build one single WAR
archive of the Maven application and switch the profiles according to the environment variables (SPRING_PROFILES_ACTIVE=dev
/SPRING_PROFILES_ACTIVE=prod
), for example. What is the best practice way to build a project via Maven to achieve this? One of the ways to solve this is to make mocked properties I suppose but I don’t think it’s a good approach.
I am thinking of linking Maven and Spring Boot profiles but still I am not sure how to properly create WAR archive because of the mentioned error.
I have two Spring Boot application profiles with three correspondent YAML files: application.yml
, application-dev.yml
and application-prod.yml
. When I run the application locally from the Idea with, for instance, dev
active profile, everything works great.
I am using Spring-boot 3.0.13 and Maven 3.9.5