Skip to content

Update 2.2 release notes to note that spring-boot:run now forks a new JVM by default #18638

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

Closed
ryenus opened this issue Oct 17, 2019 · 4 comments
Assignees
Labels
type: wiki-documentation A documentation update required on the wiki
Milestone

Comments

@ryenus
Copy link

ryenus commented Oct 17, 2019

After updating to spring boot version 2.2.0.RELEASE, some properties passed along with mvn spring-boot:run doesn't work.

For example, with a project using spring boot starter 2.2.0.RELEASE:

mvn -Dspring.profiles.active=cloud spring-boot:run

The profile reported in the console is still default:

No active profile set, falling back to default profiles: default

But when run with previous version of spring boot maven plugin

mvn -Dspring.profiles.active=cloud \
org.springframework.boot:spring-boot-maven-plugin:2.1.9.RELEASE:run

The active profile is then reported correctly:

The following profiles are active: cloud

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Oct 17, 2019
@wilkinsona
Copy link
Member

Thanks for the report. You are passing a system property into Maven's JVM and relying upon this being the same JVM as the one that runs your application. The doesn't hold true in 2.2 where we switched to forking by default. You should use -Dspring-boot.run.jvmArguments to pass arguments to the JVM that runs your app and we should check that this change is mentioned in the release notes for 2.2.

@wilkinsona wilkinsona added type: wiki-documentation A documentation update required on the wiki and removed status: waiting-for-triage An issue we've not yet triaged labels Oct 17, 2019
@wilkinsona wilkinsona added this to the 2.2.x milestone Oct 17, 2019
@wilkinsona wilkinsona changed the title properties problem with spring-boot-maven-plugin 2.2.0 Update 2.2 release notes to note that spring-boot:run now forks a new JVM by default Oct 17, 2019
@ryenus
Copy link
Author

ryenus commented Oct 17, 2019

@wilkinsona thank you for the prompt response!
I just did a quick check with -Dspring-boot.run.jvmArguments and it worked:

mvn -Dspring-boot.run.jvmArguments=-Dspring.profiles.active=cloud spring-boot:run

However, with fork mode now on by default, it becomes problematic to start a debug process when launched within Intellij IDEA for me, I was wondering why the debug session could no longer be attached, and this seems to be the cause. (yeah, I probably should use Application.main directly)

May I ask if there's a way to turn off the fork mode when using mvn spring-boot:run?


A side note, to set active spring profiles, another way is to use the environment variable SPRING_PROFILES_ACTIVE, which works consistently regardless fork mode is on of off.

@ryenus
Copy link
Author

ryenus commented Oct 17, 2019

Ah, never mind, I figured it out:

mvn -Dspring-boot.run.fork=false spring-boot:run

Reference: https://docs.spring.io/spring-boot/docs/current/maven-plugin/run-mojo.html#fork

@snicoll
Copy link
Member

snicoll commented Oct 23, 2019

A section has been added in the release notes.

@snicoll snicoll closed this as completed Oct 23, 2019
domingogallardo added a commit to domingogallardo/practicas-mads that referenced this issue Mar 4, 2021
La versión 2.2 hace que el plugin de Maven lance la aplicación en una nueva JVM
spring-projects/spring-boot#18638
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: wiki-documentation A documentation update required on the wiki
Projects
None yet
Development

No branches or pull requests

4 participants