Improved spring-properties-file-outside-jar with new 2.4.0 feature

This commit is contained in:
Gerardo Roza
2021-01-15 16:00:03 -03:00
parent 6a901441a3
commit fc96b3e97c
4 changed files with 42 additions and 7 deletions

View File

@@ -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
management.endpoint.shutdown.enabled=true
spring.config.import=file:./additional.properties,optional:file:/Users/home/config/jdbc.properties

View File

@@ -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");
}
}