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.
In SpringBoot 2.3.0 or later, the placeholder used for the value of @PropertySource fails to be resolved.
[Rails] Where to be careful in the description of validation
How to change the setting value of Springboot Hikari CP
[Rails] Where to be careful in the description of validation
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
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
[Java] [Microsoft] Things to be aware of when including the JDBC driver for SQL Server in one jar
Summarize the life cycle of Java objects to be aware of in Android development
[Rails] Where to be careful in the description of validation
I want to get the value in Ruby
Install multiple submit buttons in Rails View to get the value of the pressed button
Sample code to assign a value in a property file to a field of the expected type