BAEL 3234 - Add missing code snippets from the Spring Properties article (#9280)

This commit is contained in:
sasam0320 2020-05-13 11:09:41 +02:00 committed by GitHub
parent 856b818a2f
commit 020837fa2f
4 changed files with 25 additions and 4 deletions

View File

@ -0,0 +1,19 @@
<?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.2.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
>
<context:property-placeholder location="classpath:database.properties"/>
<bean id="dataSource" class="com.baeldung.configurationproperties.Database">
<property name="url" value="${jdbc.url}" />
<property name="username" value="${database.username}" />
<property name="password" value="${database.password}" />
</bean>
</beans>

View File

@ -7,7 +7,8 @@
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd" http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
> >
<context:property-placeholder location="classpath:foo.properties,classpath:bar.properties, classpath:database.properties"/>
<context:property-placeholder location="classpath:foo.properties,classpath:bar.properties,classpath:database.properties"/>
<bean id="componentInXmlUsingProperties" class="com.baeldung.properties.core.ComponentInXmlUsingProperties"> <bean id="componentInXmlUsingProperties" class="com.baeldung.properties.core.ComponentInXmlUsingProperties">
<constructor-arg value="${key.something}"/> <constructor-arg value="${key.something}"/>

View File

@ -1,4 +1,5 @@
database.url=jdbc:postgresql:/localhost:5432/instance
jdbc.url=jdbc:postgresql:/localhost:5432
database.username=foo database.username=foo
database.password=bar database.password=bar
jdbc.url=jdbc:postgresql:/localhost:5432

View File

@ -6,7 +6,7 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@SpringJUnitConfig(locations = "classpath:configForProperties.xml") @SpringJUnitConfig(locations = {"classpath:configForProperties.xml", "classpath:configForDbProperties.xml"})
public class MultiplePropertiesXmlConfigIntegrationTest { public class MultiplePropertiesXmlConfigIntegrationTest {
@Value("${key.something}") private String something; @Value("${key.something}") private String something;