diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithPlaceHolderConfigurer.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithPlaceHolderConfigurer.java deleted file mode 100644 index 512ecda266..0000000000 --- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertiesWithPlaceHolderConfigurer.java +++ /dev/null @@ -1,21 +0,0 @@ -package com.baeldung.properties.spring; - -import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -@Configuration -public class PropertiesWithPlaceHolderConfigurer { - - public PropertiesWithPlaceHolderConfigurer() { - super(); - } - - @Bean - public PropertyPlaceholderConfigurer propertyConfigurer() { - final PropertyPlaceholderConfigurer props = new PropertyPlaceholderConfigurer(); - props.setSystemPropertiesMode(PropertyPlaceholderConfigurer.SYSTEM_PROPERTIES_MODE_FALLBACK); - return props; - } - -} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertyPlaceholderConfig.java b/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertyPlaceholderConfig.java deleted file mode 100644 index 0d1eb4ccf7..0000000000 --- a/spring-boot-modules/spring-boot-properties/src/main/java/com/baeldung/properties/spring/PropertyPlaceholderConfig.java +++ /dev/null @@ -1,23 +0,0 @@ -package com.baeldung.properties.spring; - -import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.*; - -@Configuration -public class PropertyPlaceholderConfig { - - public PropertyPlaceholderConfig(){ - super(); - } - - @Bean - public static PropertyPlaceholderConfigurer properties() { - PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); - Resource[] resources = new ClassPathResource[]{ new ClassPathResource("foo.properties") }; - ppc.setLocations( resources ); - ppc.setIgnoreUnresolvablePlaceholders( true ); - return ppc; - } -} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertyPlaceholderBeans.xml b/spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertyPlaceholderBeans.xml index a296cf5169..fd2731df36 100644 --- a/spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertyPlaceholderBeans.xml +++ b/spring-boot-modules/spring-boot-properties/src/main/resources/configForPropertyPlaceholderBeans.xml @@ -3,15 +3,6 @@ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd" > - - - - classpath:foo.properties - - - - - diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersJavaConfigIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersJavaConfigIntegrationTest.java index 8ebda90321..6c88623ab7 100644 --- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersJavaConfigIntegrationTest.java +++ b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/multiple/MultiplePlaceholdersJavaConfigIntegrationTest.java @@ -4,12 +4,11 @@ import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Value; import org.springframework.test.context.junit.jupiter.SpringJUnitConfig; -import com.baeldung.properties.spring.PropertyPlaceholderConfig; import com.baeldung.properties.spring.PropertySourcesPlaceholderConfig; import static org.assertj.core.api.Assertions.assertThat; -@SpringJUnitConfig({PropertyPlaceholderConfig.class, PropertySourcesPlaceholderConfig.class}) +@SpringJUnitConfig({PropertySourcesPlaceholderConfig.class}) public class MultiplePlaceholdersJavaConfigIntegrationTest { @Value("${key.something}") diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesIntegrationTest.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesIntegrationTest.java deleted file mode 100644 index 374a502e5c..0000000000 --- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/ParentChildPropertyPlaceHolderPropertiesIntegrationTest.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.baeldung.properties.parentchild; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.core.env.Environment; -import org.springframework.test.context.ContextConfiguration; -import org.springframework.test.context.ContextHierarchy; -import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; -import org.springframework.test.context.web.WebAppConfiguration; -import org.springframework.web.context.WebApplicationContext; - -import com.baeldung.properties.parentchild.config.ChildConfig2; -import com.baeldung.properties.parentchild.config.ParentConfig2; - -@RunWith(SpringJUnit4ClassRunner.class) -@WebAppConfiguration -@ContextHierarchy({ @ContextConfiguration(classes = ParentConfig2.class), @ContextConfiguration(classes = ChildConfig2.class) }) -public class ParentChildPropertyPlaceHolderPropertiesIntegrationTest { - - @Autowired - private WebApplicationContext wac; - - @Test - public void givenPropertyPlaceHolder_whenGetPropertyUsingEnv_thenCorrect() { - final Environment childEnv = wac.getEnvironment(); - final Environment parentEnv = wac.getParent().getEnvironment(); - - assertNull(parentEnv.getProperty("parent.name")); - assertNull(parentEnv.getProperty("child.name")); - - assertNull(childEnv.getProperty("parent.name")); - assertNull(childEnv.getProperty("child.name")); - } - - @Test - public void givenPropertyPlaceHolder_whenGetPropertyUsingValueAnnotation_thenCorrect() { - final ChildValueHolder childValueHolder = wac.getBean(ChildValueHolder.class); - final ParentValueHolder parentValueHolder = wac.getParent().getBean(ParentValueHolder.class); - - assertEquals(parentValueHolder.getParentName(), "parent"); - assertEquals(parentValueHolder.getChildName(), "-"); - - assertEquals(childValueHolder.getParentName(), "-"); - assertEquals(childValueHolder.getChildName(), "child"); - } - -} diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ChildConfig2.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ChildConfig2.java deleted file mode 100644 index a506060d1c..0000000000 --- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ChildConfig2.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.properties.parentchild.config; - -import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ClassPathResource; - -import com.baeldung.properties.parentchild.ChildValueHolder; - -@Configuration -public class ChildConfig2 { - - @Bean - public ChildValueHolder childValueHolder() { - return new ChildValueHolder(); - } - - @Bean - public static PropertyPlaceholderConfigurer properties() { - final PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); - ppc.setLocations(new ClassPathResource("child.properties")); - return ppc; - } -} diff --git a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ParentConfig2.java b/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ParentConfig2.java deleted file mode 100644 index f5376e0c8e..0000000000 --- a/spring-boot-modules/spring-boot-properties/src/test/java/com/baeldung/properties/parentchild/config/ParentConfig2.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.baeldung.properties.parentchild.config; - -import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.ClassPathResource; - -import com.baeldung.properties.parentchild.ParentValueHolder; - -@Configuration -public class ParentConfig2 { - - @Bean - public ParentValueHolder parentValueHolder() { - return new ParentValueHolder(); - } - - @Bean - public static PropertyPlaceholderConfigurer properties() { - final PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer(); - ppc.setLocations(new ClassPathResource("parent.properties")); - return ppc; - } -}