I have a private, auto-configured library that is used by 17 micro-services in Production. This library exposes a bean that requires access to the property, spring.application.name
. In these services, this property is defined in bootstrap.yml
.
I created a new micro-service that uses this library but started getting the following exception:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'acme.LoggingConfiguration': Unexpected exception during bean creation; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.application.name' in value "${spring.application.name}"
The only difference between this service and the others is the version of Spring Boot. The working services use 2.3.7 while the broken service is using 2.4.2. I have tested the new service using Spring Boot 2.3.7.RELEASE and it works just fine.
When I set a breakpoint on PropertyPlaceholderHelper.java:178
, I see that there are only two property sources available: environment and command-line. All other property sources are missing.
Comment From: wilkinsona
Thanks for the report. Unfortunately, I don't think we'll be able to diagnose this without knowing more about your library and how it's being used. To that end, can you please provide a minimal sample that reproduces the problem? You can share it with us by zipping it up and attaching it to this issue or by pushing it to a separate repository on GitHub.
Comment From: fdutton
In providing the minimal sample, I was able to refine the actual issue. It is not related to having an auto-config library or even a library. The Spring Boot 2.3.7.RELEASE projects only work because they include spring-cloud-starter-config Hoxton.SR9. The new 2.4.2 project uses spring-cloud 2020.0.0.
The sample includes the older code with (working) and without (broken) Spring Cloud and the new code with Spring Cloud.
https://github.com/fdutton/SB-25098
Let me know if I need to create a ticket in the Spring Cloud project.
Comment From: mbhave
Thanks for the sample @fdutton. Starting with Spring Cloud 2020.0.0, bootstrap is no longer enabled by default in favor of recent changes made in Spring Boot 2.4 related to ConfigData. This is mentioned in the Spring Cloud release notes. You can fix this by moving spring.application.name
to application.yml
or by enabling bootstrap.
Comment From: fdutton
@mbhave Thanks for the info. Just so I make the right decision from the choices presented in the release notes, can you provide the rationale for removing the bootstrap feature?
Comment From: mbhave
The ConfigData changes in Spring Boot 2.4
meant that Spring Cloud could use those APIs to load properties from a config server, making Spring Cloud's bootstrap unnecessary. You can find documentation about how to use spring.config.import
with the config client here.