Q:

Spring Boot - Could not resolve placeholder when ran from jar file

I'm running into this strange issue where I can run my Spring Boot application without problems from within Intellij, but when I do:
mvn clean package -Pst -Dspring.profiles.active=st && java -jar target/myapp-0.0.1-SNAPSHOT.jar

I can see errors saying Spring Boot cannot resolve the @Value placeholders.
ERROR o.s.boot.SpringApplication - Application startup failed
java.lang.IllegalArgumentException: Could not resolve placeholder

What I did to investigate was to get the jar file and extract the files like using jar xf myapp.jar and I can see the properties files in the classpath root. Initially I had this problem that Maven was not packaging my properties and statics from the main/resource folder, but I already resolved that with:
            <resource>
                <directory>src/main/resources</directory>
            </resource>
            <resource>
                <directory>static</directory>
                <targetPath>static</targetPath>
            </resource>

Any comments, ideas what could I be missing here?

A:

I managed to resolve this. It was really weird, it seems that I need to tell java in which profile to run the jar in e.g --spring.profiles.active=st.
mvn clean package -Pst -Dspring.profiles.active=st && java -jar target/myapp-0.0.1-SNAPSHOT.jar --spring.profiles.active=st

