Merge pull request #10432 from rozagerardo/rozagerardo/JAVA-3720_Update-articles-for-2.4.0--articles-using-profiles-1

[JAVA-3720] Update articles for 2.4.0 - articles using spring.profiles.* properties -- part 1
This commit is contained in:
Loredana Crusoveanu 2021-01-20 11:20:37 +02:00 committed by GitHub
commit ed793f68ec
6 changed files with 40 additions and 7 deletions

View File

@ -11,6 +11,7 @@ app.name=MyApp
app.description=${app.name} is a Spring Boot application
logging.file.name=myapplication.log
bael.property=defaultValue
bael.otherProperty=defaultOtherValue
#---
spring.config.activate.on-profile=multidocument-dev
spring.datasource.password=password
@ -18,6 +19,9 @@ spring.datasource.url=jdbc:h2:dev
spring.datasource.username=SA
bael.property=devValue
#---
spring.config.activate.on-profile=multidocument-integration-extension
bael.otherProperty=integrationExtensionOtherValue
#---
spring.config.activate.on-profile=multidocument-prod
spring.datasource.password=password
spring.datasource.url=jdbc:h2:prod

View File

@ -1,5 +1,9 @@
bael:
root-level-property: defaultRootLevelValue
spring:
profiles:
group:
multidocument-integration: multidocument-integration-extension
---
spring:
config:

View File

@ -17,12 +17,16 @@ public class IntegrationMultidocumentFilesIntegrationTest {
@Value("${bael.property}")
private String baelCustomProperty;
@Value("${bael.otherProperty}")
private String baelCustomOtherProperty;
@Value("${bael.root-level-property}")
private String baelRootProperty;
@Test
public void givenProductionProfileActive_whenApplicationStarts_thenDefaultPropertiesUser() {
assertThat(baelCustomProperty).isEqualTo("integrationValue");
assertThat(baelCustomOtherProperty).isEqualTo("integrationExtensionOtherValue");
assertThat(baelRootProperty).isEqualTo("defaultRootLevelValue");
}
}

View File

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>client</artifactId>
<name>client</name>
@ -26,6 +26,17 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>

View File

@ -33,8 +33,7 @@
</dependencyManagement>
<properties>
<spring-cloud-dependencies.version>Hoxton.SR4</spring-cloud-dependencies.version>
<spring-boot.version>2.3.3.RELEASE</spring-boot.version>
<spring-cloud-dependencies.version>2020.0.0</spring-cloud-dependencies.version>
</properties>
</project>

View File

@ -1,11 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>server</artifactId>
<name>server</name>
<parent>
<groupId>com.baeldung.spring.cloud</groupId>
<artifactId>spring-cloud-config</artifactId>
@ -30,6 +30,17 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>