Now that you have the properties path for Applicationcontext.xml, Java no longer has to set the properties path.
Applicationcontext.xml
Before change:
<!--Properties--
<context:property-placeholder location= "File:/sb/env.properties"/>
After the change:
<!--Properties--
<bean class= "Jp.co.softbank.faqapi.common.conf.AppConfig" >
<property name= "Locations" >
<list>
<value>file:/sb/env.properties</value>
</list>
</property>
</bean>
Java files:
Import java.util.Properties;
Import org.springframework.beans.BeansException;
Import Org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
Import Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;
Import org.springframework.stereotype.Component;
/**
*コンフィギュレーション.
*/
@Component
public class AppConfig extends Propertyplaceholderconfigurer {
private properties Properties;
@Override
protected void Processproperties (Configurablelistablebeanfactory beanfactorytoprocess, properties properties) throws beansexception {
Super.processproperties (beanfactorytoprocess, properties);
This.properties = properties;
}
/**
* Envのプロパティ obtained
* @param keyキー
* @return
*/
public string Getenvproperty (string key) {
return Properties.getproperty (key);
}
}
SPINGMVC External Properties File read (Java Recycle properties content)