[BAEL-17473] - Moved articles to corrrect places, formatted pom.xmls and added description in readme files

This commit is contained in:
amit2103
2019-10-06 12:27:05 +05:30
parent 4f22a71702
commit be24e03a48
17 changed files with 95 additions and 82 deletions

View File

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

View File

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

View File

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

View File

@@ -1,4 +0,0 @@
db.url=jdbc:postgresql://localhost:5432/
db.username=admin
db.password=root
spring.main.allow-bean-definition-overriding=true

View File

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