Active Profile Spring MVC应用程序Yml

时间:2018-09-05 21:49:39

标签: spring-mvc spring-profiles

我无法从Spring MVC应用程序中的application.yml文件设置活动配置文件。

我的application.yml是

<ul class="pagination">
    <li><a href="http://localhost:8000/productos?page=1" rel="prev">&laquo;</a></li>
    <li><a href="http://localhost:8000/productos?page=1">1</a></li>
    <li class="active"><span>2</span></li>
    <li><a href="http://localhost:8000/productos?page=3">3</a></li>
    <li><a href="http://localhost:8000/productos?page=3" rel="next">&raquo;</a></li>
</ul>

我按如下方式加载Yaml:

spring:
  profiles:
    active: dev

我的环境活动配置文件始终为空

 @Bean
 public static PropertySourcesPlaceholderConfigurer properties() {
    PropertySourcesPlaceholderConfigurer 
                    propertySourcesPlaceholderConfigurer = new 
                          PropertySourcesPlaceholderConfigurer();
    YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
    yaml.setResources(new ClassPathResource("application.yml"));
    propertySourcesPlaceholderConfigurer.setProperties(yaml.getObject());
    return propertySourcesPlaceholderConfigurer;
}

请帮助

0 个答案:

没有答案