-
Notifications
You must be signed in to change notification settings - Fork 41.2k
spring.profiles.include
working w/ 2.3.9, broken w/ 2.4.2
#25759
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
@philwebb Here you go. Please let me know if you have any questions at all regarding the reproduction. I tried to make it as simple as possible. Thank you for your time! |
Thanks for the demo @workmanw. Unfortunately the error you're seeing is due to an intentional change we made in 2.4. We no longer allow For your sample, I wonder if using @ExtendWith(SpringExtension.class)
@SpringBootTest(
webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT,
properties = "spring.profiles.include=logging"
)
class DemoApplicationTests {
// ...
} That would be allowed since the
Does that change work for your real application? |
@philwebb For our Integration Tests removing the Backstory: Our Do you have any suggestions on how to solve this? If you would like me to amend the reproduction to encompass this secondary scenario I'd be happy to do so. |
@workmanw You can try the new If you add the following to your spring:
profiles:
group:
"dev": "logging"
"qa": "logging"
"prod": "logging" |
Actually it seems pretty straight forward to me, unless there is something I'm overlooking. I don't love that it has to go into the main Stepping back, am I approaching this problem right by using profiles this way? Is there a better solution? We definitely want to align with best practices as much as possible. Sorry if this is turning into a support issue. Just trying to figure out what is the best path forward. Thank you for all your help! |
If your main goal is to extract common config so that you can include it, you might want to try So you might have a file called logging:
config: "classpath:demo-logback.xml"
... Then you can import that file whenever you need to. E.g. in spring:
config:
import: "./json-logging.yaml`
... We added this feature because we found a lot of people were adding profiles just as a way of getting common config imported. If you're not actually using the |
As the |
@philwebb Thanks again! |
I have to say I'm disappointed in this breaking change. The whole point for us of having separate application-dev.yml files which aren't under source control is to keep dev concerns out of the main application.yml file. |
@beardy247 FWIW That was my initial reaction as well. But once you wrap your head around |
@workmanw yes Just switch |
While upgrading to 2.4.2 we started seeing this exception on startup:
Originally we thought the issue was related to: #24733 , however after investigating further and asking for advice it was suggested I open a new issue.
In our use case we have a common library for all of our microservices platforms that configures JSON logging. Each service uses
spring.profiles.include
to import the logging configuration. We use include this way because active profile does not work due to how early in the lifecycleDefaultCacheAwareContextLoaderDelegate
is invoked.I made a simple reproduction: https://github.com/workmanw/spring-bug-demo . This demo shows it working correctly with
2.3.9
and if you change the pom to2.4.2
it will demonstrate the exception.The text was updated successfully, but these errors were encountered: