Could not resolve placeholder ‘xxx‘ in value “${xxx}“at org.springframe

1、检查配置yml或properties文件中的名字与”$(“”)”中的是否一致;

2、查看是否写在包含启动类下的resources文件夹下,配置文件写在包含Application类中才有效。

3、检查是否写在第一个配置文件(yml / properties)中,因为在第一个配置文件如果找不到就不会继续往下找,直接报错。可以在启动类(Application)中添加如下Bean,使其继续查找后续的配置文件:

    @Bean
    public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
        PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
        propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);
        return propertySourcesPlaceholderConfigurer;
    }

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://www.net2asp.com/9b622d4496.html