work on properties

This commit is contained in:
eugenp 2015-08-15 18:14:55 +03:00
parent 3bc0b756ad
commit 7243b16d49
12 changed files with 44 additions and 13 deletions

View File

@ -1,4 +1,4 @@
package org.baeldung.properties.spring;
package org.baeldung.properties.external;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;

View File

@ -1,4 +1,4 @@
package org.baeldung.properties.spring;
package org.baeldung.properties.external;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

View File

@ -1,4 +1,4 @@
package org.baeldung.properties.spring;
package org.baeldung.properties.external;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

View File

@ -1,4 +1,4 @@
package org.baeldung.properties.spring;
package org.baeldung.properties.external;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;

View File

@ -0,0 +1,23 @@
package org.baeldung.properties.spring;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
@Configuration
@PropertySource("classpath:foo.properties")
public class BasicPropertiesWithJavaConfig {
public BasicPropertiesWithJavaConfig() {
super();
}
// beans
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
}

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd"
>
<context:property-placeholder location="classpath:foo.properties" ignore-unresolvable="true" order="1"/>
</beans>

View File

@ -1,6 +1,6 @@
package org.baeldung.properties.core;
package org.baeldung.properties.basic;
import org.baeldung.properties.spring.PropertiesWithJavaConfig;
import org.baeldung.properties.spring.BasicPropertiesWithJavaConfig;
import org.baeldung.properties.spring.PropertiesWithJavaConfigOther;
import org.junit.Test;
import org.junit.runner.RunWith;
@ -12,7 +12,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.support.AnnotationConfigContextLoader;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(classes = { PropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class)
@ContextConfiguration(classes = { BasicPropertiesWithJavaConfig.class, PropertiesWithJavaConfigOther.class }, loader = AnnotationConfigContextLoader.class)
public class PropertiesWithJavaIntegrationTest {
@Autowired

View File

@ -9,7 +9,7 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:configForPropertiesOne.xml", "classpath:basicConfigForPropertiesTwo.xml" })
@ContextConfiguration(locations = { "classpath:basicConfigForPropertiesOne.xml", "classpath:basicConfigForPropertiesTwo.xml" })
public class PropertiesWithMultipleXmlsIntegrationTest {
@Autowired

View File

@ -1,6 +1,5 @@
package org.baeldung.properties.external;
import org.baeldung.properties.spring.PropertiesWithJavaConfig;
import org.baeldung.properties.spring.PropertiesWithJavaConfigOther;
import org.junit.Ignore;
import org.junit.Test;

View File

@ -1,7 +1,5 @@
package org.baeldung.properties.external;
import org.baeldung.properties.spring.PropertiesWithXmlConfigOne;
import org.baeldung.properties.spring.PropertiesWithXmlConfigTwo;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@ -1,6 +1,5 @@
package org.baeldung.properties.external;
import org.baeldung.properties.spring.PropertiesWithXmlConfig;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

View File

@ -1,8 +1,8 @@
package org.baeldung.test;
import org.baeldung.properties.basic.PropertiesWithJavaIntegrationTest;
import org.baeldung.properties.basic.PropertiesWithMultipleXmlsIntegrationTest;
import org.baeldung.properties.basic.PropertiesWithXmlIntegrationTest;
import org.baeldung.properties.core.PropertiesWithJavaIntegrationTest;
import org.baeldung.properties.external.ExternalPropertiesWithJavaIntegrationTest;
import org.baeldung.properties.external.ExternalPropertiesWithMultipleXmlsIntegrationTest;
import org.baeldung.properties.external.ExternalPropertiesWithXmlIntegrationTest;