0

I have a Maven/Spring boot project that I'm seeing some odd behavior in. To summarize, a spring profile is attempting to load, but that profile doesn't exist and isn't specified ANYWHERE in my code. It seems as if the profile name is being picked up from a different Java command line property though, which is why it is confusing me.

Essentially my command line looks something like this:

Java -DEnvironmentID=qa01 -jar myapp.jar com.something.package.Loader LOAD

From what I understand from Spring documentation's command line documentation is that I would need to call java with the -Dspring.profiles.active=profileName argument in order to invoke a profile. So while I'm NOT doing this, "qa01" is being picked as a profile and my application tries to load "application-qa01.properties"

During my testing, I've also noticed that small modifications to the "-DEnvironmentID" argument will prevent this from being picked up as a profile (ex. "qa10", "qa0", "a01", "qa100", etc...)

I'm stumped at this point and can't determine why it would be picked as a profile argument by Spring.

Jason M.
  • 692
  • 2
  • 8
  • 24

1 Answers1

0

Just in case this could help someone in the future:

The problem was rooted in a dependency of my project. The dependency happened to use the same command line argument as my own to build out a path to the environment specific properties file packaged within the jar. The dependency project just happened to build out the properties file name/path just like a Spring profile, so it ended up not actually being related to profiles after all. When the dependency jar failed to provide the properties file, Spring continued to look for the file in my project, eventually throwing the error.

Jason M.
  • 692
  • 2
  • 8
  • 24