properties logic moved entirelly under a package

This commit is contained in:
eugenp
2013-06-01 11:47:10 +03:00
parent 52995a5194
commit a7eeabc8de
8 changed files with 63 additions and 30 deletions
@@ -1,4 +1,4 @@
package org.baeldung.core;
package org.baeldung.properties.core;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
@@ -23,8 +23,8 @@ public class ComponentUsingProperties implements InitializingBean {
@Override
public void afterPropertiesSet() throws Exception {
System.out.println("via @Value: " + injectedProperty);
System.out.println("via Environment: " + env.getProperty("key.something"));
System.out.println("in afterPropertiesSet via @Value: " + injectedProperty);
System.out.println("in afterPropertiesSet Environment: " + env.getProperty("key.something"));
}
}
@@ -0,0 +1,25 @@
package org.baeldung.properties.spring;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@Configuration
@ComponentScan("org.baeldung.core")
@PropertySource("classpath:foo.properties")
public class PropertiesWithJavaConfig {
public PropertiesWithJavaConfig() {
super();
}
// beans
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}
@@ -1,14 +1,13 @@
package org.baeldung.spring.properties;
package org.baeldung.properties.spring;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
@ImportResource("classpath:configForProperties.xml")
@ComponentScan("org.baeldung.core")
public class PropertiesWithXmlConfig extends WebMvcConfigurerAdapter {
public class PropertiesWithXmlConfig {
public PropertiesWithXmlConfig() {
super();
@@ -1,17 +0,0 @@
package org.baeldung.spring.properties;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
@Configuration
@ComponentScan("org.baeldung.core")
@PropertySource("classpath:foo.properties")
public class PropertiesWithJavaConfig extends WebMvcConfigurerAdapter {
public PropertiesWithJavaConfig() {
super();
}
}