You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Eclipse Spring Tools Sometimes Doesn't Honor Profile or any Override Properties #1432
Describe the bug
Using Spring Tool Suite 4 for Eclipse - 4.27.0.202411281623
To Reproduce
There are some spring boot projects, all of the same version.......now the newly released 3.4.0 where the profile is not honored nor any of the override properties. The application simply starts up as "default" profile and fails to start up. I can't figure out what is different between one project vs. the next as they are all based on the same parent project.
In the above project, it's based on Spring Boot 3.4.0 and when I start it up the profile nor override properties are honored. I have another project with the same settings and it honors both the profile and override properties.
@cabbonizio Unfortunately I wasn't able to reproduce this with something simple like PetClinic project... Do you mind attaching some trimmed down sample project? Thanks in advance!-)
@BoykoAlex I figured it out...........this one very popular line in Spring Boot apps. This is usually a line we don't pay attention to but it's been right under our nose all along. Newer apps using the DevTools to create project do it properly with the "args" param.......some of our older apps may be been more hand typed with adding "args" being an afterthought. If this is working as designed you can close this. Many thanks for having a look at this.
Service that does not work: SpringApplication.run(Application.class);
Service that does work: SpringApplication.run(Application.class, args);
@cabbonizio Thanks a lot for the update and great that you found the issue here. The launch configuration indeed turns the selected profiles into a command line arg like --spring.profiles.active=prof, which only makes it into the application if you pass on the args parameter to the SpringApplication.run method. So we could say that this "works as designed".
But we could (and maybe should) change the way the launch configuration turns those settings into arguments for the application and switch this over to set system properties instead - which would make it into the application independent of the exact way you implement the main method.
Activity
BoykoAlex commentedon Dec 6, 2024
@cabbonizio Unfortunately I wasn't able to reproduce this with something simple like PetClinic project... Do you mind attaching some trimmed down sample project? Thanks in advance!-)
cabbonizio commentedon Dec 7, 2024
I'm comparing the dependencies right now to see if there's something maybe on the classpath that's causing this issue:
And the one that does work:
cabbonizio commentedon Dec 7, 2024
@BoykoAlex I figured it out...........this one very popular line in Spring Boot apps. This is usually a line we don't pay attention to but it's been right under our nose all along. Newer apps using the DevTools to create project do it properly with the "args" param.......some of our older apps may be been more hand typed with adding "args" being an afterthought. If this is working as designed you can close this. Many thanks for having a look at this.
Service that does not work:
SpringApplication.run(Application.class);Service that does work:
SpringApplication.run(Application.class, args);martinlippert commentedon Dec 18, 2024
@cabbonizio Thanks a lot for the update and great that you found the issue here. The launch configuration indeed turns the selected profiles into a command line arg like
--spring.profiles.active=prof, which only makes it into the application if you pass on theargsparameter to theSpringApplication.runmethod. So we could say that this "works as designed".But we could (and maybe should) change the way the launch configuration turns those settings into arguments for the application and switch this over to set system properties instead - which would make it into the application independent of the exact way you implement the
mainmethod.@BoykoAlex What do you think?
BoykoAlex commentedon Jan 16, 2025
Yes, we could turn these into system properties... I cannot think of an argument against that so I'll give it a try.
BoykoAlex commentedon Jan 16, 2025
Fixed via 05cb65e