Search code examples
javawildflywildfly-10

Wildfly 10 Can I set -Dspring.profiles.active in standalone.conf.bat?


Edit: I've tried adding set "JAVA_OPTS=%JAVA_OPTS% -Dspring.profiles.active=test" inside standalone.conf.bat and this hasn't worked. It's as if it's being ignored.


Is it possible to set -Dspring.profiles.active=testlike one might if calling

java -Dspring.profiles.active=test -jar build/libs/weather-0.0.1-SNAPSHOT.jar

as a line in standalone.conf.bat? If not, what is the reason?

I've tried this (as well as in domain.conf.bat and appclient.conf.bat) and it seems to be completely ignored (I killed the java process and restarted the wildfly service to have the war redeployed). This is running on Windows 10.

Edit: it works perfectly fine when doing it from IntelliJ and running it in debug. I just want to be able to reproduce this on wildfly.


Solution

  • I discovered the problem and it relates to specific changes to other .bat files made by other people who worked on this project within the "standalone" directory. There was some strange interference with how %JAVA_OPTS% was being set (and overwritten). Even though server.log logged (multiple times that -Dspring.profiles.active=test was set, it wasn't "sticking".

    I resolved this by doing a dive into all the places the VM args were messed with in the .bats in standalone, using recursive file search in Notepad++. The takeaway for anyone else is that, if running on windows, you should be able to set -Dspring.profiles.active=test (or whatever your arg is) in standalone.conf (and nowhere else), and that should be sufficient to carry-over into the wildfly java.exe process.