In SpringBoot 2.3.0 or later, the placeholder used for the value of @PropertySource fails to be resolved.

Contents

The title is as it is. In SpringBoot 2.3.0 or later, if you use a placeholder like classpath: /something-config-${spring.profiles.active} .yml to specify the value of @ PropertySource, you will not be able to resolve it and an exception will occur. appear. The latest version of Boot today is 2.3.1.

Source

SomethingConfig.java


@Configuration
@ConfigurationProperties(prefix = "something")
@Component
@PropertySource(value = {"classpath:/something-config.yml","classpath:/something-config-${spring.profiles.active}.yml"}, factory = YamlPropertySourceFactory.class)
@Data
public class SomethingConfig {

    private String setting1;
    private String setting2;
}

result

Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.profiles.active' in value "classpath:/somethign-config-${spring.profiles.active}.yml"

Solution

I used 2.2 series for the time being.

issue

https://github.com/spring-projects/spring-boot/issues/21631

Recommended Posts

In SpringBoot 2.3.0 or later, the placeholder used for the value of @PropertySource fails to be resolved.
How to change the setting value of Springboot Hikari CP
[Rails] Where to be careful in the description of validation
[Java] How to search for a value in an array (or list) with the contains method
I want to change the value of Attribute in Selenium of Ruby
How to increment the value of Map in one line in Java
[Spring Boot] List of validation rules that can be used in the property file for error messages
What to do if JavaMail cannot be used with OpenJDK 11 or later
Procedure to make the value of the property file visible in Spring Boot
How to change the value of a variable at a breakpoint in intelliJ
Android development, how to check null in the value of JSON object
Warning to the nested class of AsyncTask defined in Activity "This'AsyncTask' class should be static or leaks might occur"
[Java] [Microsoft] Things to be aware of when including the JDBC driver for SQL Server in one jar
graphql-ruby: How to get the name of query or mutation in controller Note
How to display the amount of disk used by Docker container for each container
Be absolutely careful when putting the result of and / or in a variable!
When the server fails to start in Eclipse
I want to get the value in Ruby
Pass the condition to be used in the Java8 lambda expression filter () as a parameter
For those who want to use MySQL for the database in the environment construction of Rails6 ~.
How to set the log level to be displayed in the release version of orhanobut / logger
Install multiple submit buttons in Rails View to get the value of the pressed button
[Active Admin] I want to specify the scope of the collection to be displayed in select_box
Sample code to assign a value in a property file to a field of the expected type