Improved spring-properties-file-outside-jar with new 2.4.0 feature
This commit is contained in:
parent
1c5185b549
commit
6b462cd6c6
|
@ -0,0 +1 @@
|
|||
bael.property1=value1
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
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>
|
||||
|
||||
|
@ -88,7 +89,6 @@
|
|||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-context</artifactId>
|
||||
<version>${springcloud.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
@ -99,6 +99,18 @@
|
|||
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring.cloud-version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<resources>
|
||||
|
@ -153,9 +165,8 @@
|
|||
<jpa.version>2.2</jpa.version>
|
||||
<guava.version>18.0</guava.version>
|
||||
<subethasmtp.version>3.1.7</subethasmtp.version>
|
||||
<springcloud.version>2.0.2.RELEASE</springcloud.version>
|
||||
<httpclient.version>4.5.8</httpclient.version>
|
||||
<spring-boot.version>2.3.3.RELEASE</spring-boot.version>
|
||||
<spring.cloud-version>2020.0.0</spring.cloud-version>
|
||||
</properties>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -2,6 +2,7 @@ management.endpoints.web.exposure.include=*
|
|||
management.metrics.enable.root=true
|
||||
management.metrics.enable.jvm=true
|
||||
management.endpoint.restart.enabled=true
|
||||
spring.datasource.jmx-enabled=false
|
||||
spring.datasource.tomcat.jmx-enabled=false
|
||||
spring.main.allow-bean-definition-overriding=true
|
||||
management.endpoint.shutdown.enabled=true
|
||||
spring.config.import=file:./additional.properties,optional:file:/Users/home/config/jdbc.properties
|
|
@ -0,0 +1,22 @@
|
|||
package com.baeldung.properties;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
|
||||
@SpringBootTest
|
||||
public class ApplicationPropertyImportExternalFileIntegrationTest {
|
||||
|
||||
@Value("${bael.property1}")
|
||||
String baelProperty;
|
||||
|
||||
@Test
|
||||
public void whenExternalisedPropertiesLoadedUsinApplicationProperties_thenReadValues() throws IOException {
|
||||
assertEquals(baelProperty, "value1");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue