use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project tutorials by eugenp.
the class ParentConfig2 method configurer.
@Bean
public static PropertyPlaceholderConfigurer configurer() {
final PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
ppc.setLocations(new ClassPathResource("parent.properties"));
return ppc;
}
use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project jim-framework by jiangmin168168.
the class WebApplicationConfig method properties.
@Bean
public static PropertyPlaceholderConfigurer properties() {
SpringPropertyInjectSupport springPropertyInjectSupport = new SpringPropertyInjectSupport();
springPropertyInjectSupport.setConfigNameSpaces("configcenter/" + System.getProperty("env"));
springPropertyInjectSupport.init();
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
Resource[] resources = new ClassPathResource[] { new ClassPathResource("application.properties") };
ppc.setLocations(resources);
ppc.setIgnoreUnresolvablePlaceholders(true);
return ppc;
}
use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project eol-globi-data by jhpoelen.
the class Config method properties.
@Bean
public static PropertyPlaceholderConfigurer properties() {
PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
ppc.setIgnoreResourceNotFound(true);
ppc.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_OVERRIDE);
return ppc;
}
use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project webapp by elimu-ai.
the class EnvironmentContextLoaderListener method customizeContext.
@Override
protected void customizeContext(ServletContext servletContext, ConfigurableWebApplicationContext applicationContext) {
logger.info("customizeContext");
// Load default settings
try {
Resource resourceConfig = new ServletContextResourceLoader(servletContext).getResource("classpath:config.properties");
PROPERTIES.load(resourceConfig.getInputStream());
Resource resourceJdbc = new ServletContextResourceLoader(servletContext).getResource("classpath:jdbc.properties");
PROPERTIES.load(resourceJdbc.getInputStream());
logger.debug("properties (before overriding): " + PROPERTIES);
} catch (IOException ex) {
logger.error(ex);
}
if ((env == Environment.TEST) || (env == Environment.PROD)) {
InputStream inputStream = null;
try {
// Override config.properties
Resource resourceConfig = new ServletContextResourceLoader(servletContext).getResource("classpath:config_" + env + ".properties");
PROPERTIES.load(resourceConfig.getInputStream());
// Override jdbc.properties
Resource resourceJdbc = new ServletContextResourceLoader(servletContext).getResource("classpath:jdbc_" + env + ".properties");
PROPERTIES.load(resourceJdbc.getInputStream());
String contentLanguage = (String) servletContext.getAttribute("content_language");
logger.info("contentLanguage: " + contentLanguage);
PROPERTIES.put("content.language", contentLanguage);
String jdbcUrl = (String) servletContext.getAttribute("jdbc_url");
PROPERTIES.put("jdbc.url", jdbcUrl);
String jdbcUsername = (String) servletContext.getAttribute("jdbc_username");
PROPERTIES.put("jdbc.username", jdbcUsername);
String jdbcPasswordAttr = (String) servletContext.getAttribute("jdbc_password");
PROPERTIES.put("jdbc.password", jdbcPasswordAttr);
String googleApiSecret = (String) servletContext.getAttribute("google_api_secret");
PROPERTIES.put("google.api.secret", googleApiSecret);
String gitHubApiSecret = (String) servletContext.getAttribute("github_api_secret");
PROPERTIES.put("github.api.secret", gitHubApiSecret);
String covalentApiKey = (String) servletContext.getAttribute("covalent_api_key");
PROPERTIES.put("covalent.api.key", covalentApiKey);
if (env == Environment.PROD) {
String discordWebhookUrl = (String) servletContext.getAttribute("discord_webhook_url");
PROPERTIES.put("discord.webhook.url", discordWebhookUrl);
}
logger.debug("properties (after overriding): " + PROPERTIES);
} catch (FileNotFoundException ex) {
logger.error(ex);
} catch (IOException ex) {
logger.error(ex);
} finally {
try {
if (inputStream != null) {
inputStream.close();
}
} catch (IOException ex) {
logger.error(ex);
}
}
PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer();
propertyPlaceholderConfigurer.setProperties(PROPERTIES);
applicationContext.addBeanFactoryPostProcessor(new BeanFactoryPostProcessor() {
@Override
public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
PropertyPlaceholderConfigurer propertyPlaceholderConfigurer = new PropertyPlaceholderConfigurer();
propertyPlaceholderConfigurer.setProperties(PROPERTIES);
propertyPlaceholderConfigurer.postProcessBeanFactory(configurableListableBeanFactory);
}
});
}
// Add all supported languages
PROPERTIES.put("supported.languages", Language.values());
// Add config properties to application scope
servletContext.setAttribute("configProperties", PROPERTIES);
servletContext.setAttribute("newLineCharRn", "\r\n");
servletContext.setAttribute("newLineCharR", "\r");
servletContext.setAttribute("newLineCharR", "\n");
super.customizeContext(servletContext, applicationContext);
}
use of org.springframework.beans.factory.config.PropertyPlaceholderConfigurer in project kylo by Teradata.
the class TestConfig method propConfig.
@Bean
public PropertyPlaceholderConfigurer propConfig() {
PropertyPlaceholderConfigurer placeholderConfigurer = new PropertyPlaceholderConfigurer();
placeholderConfigurer.setLocation(new ClassPathResource("config.properties"));
return placeholderConfigurer;
}
Aggregations