[BAEL-17473] - Moved articles to corrrect places, formatted pom.xmls and added description in readme files
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
## Spring Boot Artifacts
|
||||
|
||||
This module contains articles about configuring the Spring Boot build process.
|
||||
|
||||
### Relevant Articles:
|
||||
- [Spring Boot Dependency Management with a Custom Parent](https://www.baeldung.com/spring-boot-dependency-management-custom-parent)
|
||||
- [Create a Fat Jar App with Spring Boot](https://www.baeldung.com/deployable-fat-jar-spring-boot)
|
||||
- [Intro to Spring Boot Starters](https://www.baeldung.com/spring-boot-starters)
|
||||
- [Spring Properties File Outside jar](https://www.baeldung.com/spring-properties-file-outside-jar)
|
||||
- [Introduction to WebJars](https://www.baeldung.com/maven-webjars)
|
||||
- [A Quick Guide to Maven Wrapper](https://www.baeldung.com/maven-wrapper)
|
||||
@@ -101,15 +101,6 @@
|
||||
|
||||
<build>
|
||||
<finalName>${project.artifactId}</finalName>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<excludes>
|
||||
<exclude>**/conf.properties</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
@@ -126,28 +117,28 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.18</version>
|
||||
<executions>
|
||||
<!-- Invokes both the integration-test and the verify goals of the Failsafe
|
||||
Maven plugin -->
|
||||
<execution>
|
||||
<id>integration-tests</id>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- Skips integration tests if the value of skip.integration.tests
|
||||
property is true -->
|
||||
<includes>
|
||||
<include>**/ExternalPropertyFileLoaderIntegrationTest.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-failsafe-plugin</artifactId>
|
||||
<version>2.18</version>
|
||||
<executions>
|
||||
<!-- Invokes both the integration-test and the verify goals of the Failsafe
|
||||
Maven plugin -->
|
||||
<execution>
|
||||
<id>integration-tests</id>
|
||||
<goals>
|
||||
<goal>integration-test</goal>
|
||||
<goal>verify</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<!-- Skips integration tests if the value of skip.integration.tests
|
||||
property is true -->
|
||||
<includes>
|
||||
<include>**/ExternalPropertyFileLoaderIntegrationTest.java</include>
|
||||
</includes>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
package com.baeldung.properties;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class ConfProperties {
|
||||
|
||||
@Value("${db.url}")
|
||||
private String url;
|
||||
|
||||
@Value("${db.username}")
|
||||
private String username;
|
||||
|
||||
@Value("${db.password}")
|
||||
private String password;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.baeldung.properties;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.core.io.FileSystemResource;
|
||||
|
||||
@Configuration
|
||||
public class ExternalPropertyConfigurer {
|
||||
|
||||
@Bean
|
||||
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
|
||||
PropertySourcesPlaceholderConfigurer properties = new PropertySourcesPlaceholderConfigurer();
|
||||
properties.setLocation(new FileSystemResource("src/main/resources/external/conf.properties"));
|
||||
properties.setIgnoreResourceNotFound(false);
|
||||
return properties;
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
package com.baeldung.properties;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||
|
||||
@SpringBootApplication
|
||||
public class ExternalPropertyFileLoader {
|
||||
|
||||
@Autowired
|
||||
ConfProperties prop;
|
||||
|
||||
public static void main(String[] args) {
|
||||
new SpringApplicationBuilder(ExternalPropertyFileLoader.class).build()
|
||||
.run(args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
db.url=jdbc:postgresql://localhost:5432/
|
||||
db.username=admin
|
||||
db.password=root
|
||||
spring.main.allow-bean-definition-overriding=true
|
||||
@@ -1,27 +0,0 @@
|
||||
package com.baeldung.properties;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||
|
||||
@RunWith(SpringJUnit4ClassRunner.class)
|
||||
@SpringBootTest(classes = ExternalPropertyFileLoader.class)
|
||||
public class ExternalPropertyFileLoaderIntegrationTest {
|
||||
|
||||
@Autowired
|
||||
ConfProperties props;
|
||||
|
||||
@Test
|
||||
public void whenExternalisedPropertiesLoaded_thenReadValues() throws IOException {
|
||||
assertEquals("jdbc:postgresql://localhost:5432/", props.getUrl());
|
||||
assertEquals("admin", props.getUsername());
|
||||
assertEquals("root", props.getPassword());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user