[JAVA]

In SpringBoot 2.3.0 oder höher kann der für den Wert von @PropertySource verwendete Platzhalter nicht aufgelöst werden. Der Inhaltstitel bleibt unverändert. Wenn Sie in SpringBoot 2.3.0 oder höher einen Platzhalter wie "classpath: /something-config-${spring.profiles.active} .yml" verwenden, um den Wert von "@ PropertySource" anzugeben, können Sie ihn nicht auflösen, und es tritt eine Ausnahme auf. Auftreten. Die neueste Version von Boot ist heute 2.3.1. Quelle

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;
}

Ergebnis

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

Lösungen

Ich habe vorerst die 2.2-Serie verwendet.

issue

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

Recommended Posts