-
Notifications
You must be signed in to change notification settings - Fork 41.2k
spring-boot:run The usage of -Dspring.profiles.active=...
should be discouraged
#16819
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There certainly seem to be a few comments about this on #1095 so I wonder if we can check if the run process is going to be forked and then print warnings if the current JVM has
This one is a little harder because the |
(
Hm, I see. Maybe using varargs in this places have not been a good idea. ;-) But ok - if one want's to change that at all - that's hard to change. One could only deprecate all |
I'm afraid that's not the case. The API is commonly used that way, but there's no hard requirement that it's always triggered from a main methods. That's one reason why var-args were used. |
Ok, I see, than there's nothing to do, I guess - which leaves item 1 on my proposals... |
FTR this was considered before and is not an oversight. That line of argument can be used for any property of any plugin forking a process. If we start producing a warning for a specific property, why not also do it for another? (you're warning us about X but not about Y). You may also have that property around and be bothered by getting a warning every time you start your app. We can use an info message and a generic message with the downside that is producing noise if you are aware of that behaviour and you might miss the message if you don't. |
Correct, that's why I wrote "always point that (VM was forked) out explicitly".
True, but I think the advantages outweigh the disadvantages. To sum it up: I'm aware of the aforementioned "pitfalls" now, but it cost me quite amount of time searching. A warning or info on screen could prevent that for future users. |
I am not sure about that but regardless this request is now a duplicate of #10926 |
Proposal for an improvement
As you can read in my off-topic follow-up questions in #16811 (comment) I ran into some problems due to the fact that the JVM was forked because of using the parameter
workingDirectory
.Some more thoughts: (cut/paste from the aforementioned issue)
Ok, I think, I got it: There are several pitfalls when defining active profiles in Spring-Boot:
-Dspring.profiles.active=...
should IMHO produce a big fat warning on screen, because it simply does not work if the JVM is forked which can implicitely happen when using specific parameters.-Dspring-boot.run.profiles=...
instead is the right way to go, but it can only be used with the Spring-Boot Maven plugin. It implicitely creates the command line argument--spring.profiles.active=...
which in return must be consumed bySpringApplication#run(...)
, therefore usingrun(...)
without args should produce a big fat warning in the logs, too.--spring.profiles.active=...
is problematic because of the aforementioned reasons. In this case the best way to go is using-Dspring.profiles.active=...
, I think.Looks a litte bit messy... ;-)
Would be interested to hear your opinion about that!
The text was updated successfully, but these errors were encountered: