当前位置: 代码迷 >> 综合 >> springboot 里面 @ImportResource()的xml 引用了 <context:property-placeholder >不起作用
  详细解决方案

springboot 里面 @ImportResource()的xml 引用了 <context:property-placeholder >不起作用

热度:22   发布时间:2023-11-22 19:10:32.0

<!--    <context:property-placeholder location="classpath:config.properties"  ignore-resource-not-found="true"  ignore-unresolvable="true" />-->

 着手把ssm 4.3.14.RELEASE项目改成springboot 2.2.2.RELEASE 

 

需要@Configuration一个 properties 配置properties的Bean 如下即可生效, 此配置类放在springboot启动类同级别的config包下


 

package com.config;import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;/*** @author wbzhongsy on 2020/8/21 update** Adds support for runtime property files. Run with -Dspring.profiles.active={production,default,development,test} defaults to development.**/@Configuration
@PropertySource(value={"classpath:Business/ALL/config.properties"})
public class PropertyConfig {public PropertyConfig() {}@Beanpublic  PropertySourcesPlaceholderConfigurer myPropertySourcesPlaceholderConfigurer() {return new PropertySourcesPlaceholderConfigurer();}
}

 

 

 

 

  相关解决方案