-
Notifications
You must be signed in to change notification settings - Fork 41.2k
-Dspring.profiles.active ignored when mvn spring-boot:run #1095
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
In 1.1.0 the plugin forks a process which is the reason why your system property is no longer available. The release notes indicate that the documentation of the maven plugin are now published. You'll find an example there |
Ah, thanks - I'll have a look and close the issue as soon as I confirm it works. |
Cheers. |
(For reference) The command should be:
|
I have also added a section in the release notes regarding this change. Thanks for the report! |
@kryger I tried your way but I could not succeed. spring.profiles.active is not a maven/pom parameter. I think there must be another way to go on command line. Are you sure that it works? I think this issue should be opened. By the way I am working with spring boot 1.2.5 release, maven 3, java 8u60 |
Sorry for misunderstanding, my fault! It was about another thing but this one works:
|
I have always liked "SPRING_PROFILES_ACTIVE=production mvn spring-boot:run". It's the way to pass lots of critical env variables to really any app, maven or whatever. |
@gregturn |
It works using: Please refer to: http://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/run-profiles.html |
The following is ignored: However, using -Drun.jvmArguments works: Using: spring-boot-maven-plugin 1.5.9.RELEASE |
That's to be expected if Maven forks a new JVM for the application. In your first example, the system property isn't being ignored, it's just being set in Maven's JVM rather than the application's JVM. The second example works as it ensures that the system property is passed to the JVM that's used to run the application. |
Thanks @wilkinsona, that makes sense. But how does this fit to the documentation? This is quite misleading:
|
@timomeinen what version of Spring Boot are you using? |
Oops. Sorry. @snicoll has just pointed out that it's |
@timomeinen alright so I think we need a sample that we can run that reproduces the behaviour you've described. Please create a separate issue with that. |
Using 1.5.9.RELEASE. I will try to create a sample application. |
The demo is working as expected. In my application just the logging is not working. This is because of my own configuration in logback-spring.xml as can be seen here: #5611 I am using Janino to get conditional processing in logback (because of the not working scan feature #5611): The problem is, that the Maven plugin won't set the That would also clarify the behaviour as given in the documentation for run.profiles:
|
It does set |
This appears to be broken on version 2.0.0.RC2 |
@cyberoblivion What do you mean by "this"? No change was made as a result of this issue so there's nothing to have been merged. You should use |
Oh sorry, yes -Drun.profiles does not seem to work in spring-boot-maven-plugin:2.0.0.RC2. example: |
My mistake, it should be |
This is also covered in the migration guide on the wiki |
That works thanks. |
Switch from spring.profiles.active to spring-boot.run.profiles See spring-projects/spring-boot#1095 (comment)
Switch from spring.profiles.active to spring-boot.run.profiles See spring-projects/spring-boot#1095 (comment)
Thanks @gregturn! |
@wilkinsona - your suggestion worked for me: #1095 (comment) |
This worked |
I tried on spring boot 2.
|
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This worked: |
For Spring Boot 2 under PowerShell, this only worked surrounding dots within quotes, for example |
Upgrading 1.0.2.RELEASE->1.1.0.RELEASE changed how passing profile to
mvn spring-boot:run
works, the-Dspring.profiles.active
flag seems to be ignored. I created a simple project that reproduces the problem: https://github.com/kryger/bug-spring-maven-profiles(Note that
application.yml
defines port=3333,application-production.yml
defines port=1111)Steps to reproduce:
mvn spring-boot:run -Dspring.profiles.active=production
-> Tomcat starts on port 3333 (expected 1111)<version>
to1.0.2.RELEASE
mvn spring-boot:run -Dspring.profiles.active=production
again -> Tomcat starts on port 1111I had a look at 1.1.0.RELEASE's release notes but couldn't find anything that would explain this change - no idea if it's a bug or a feature :).
The text was updated successfully, but these errors were encountered: