Add simple configserver

This commit is contained in:
Dave Syer
2015-12-17 21:21:08 +00:00
parent 38424b9814
commit 6c8507d73e
8 changed files with 175 additions and 4 deletions

View File

@@ -7,21 +7,27 @@ import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.client.ConfigClientProperties;
import org.springframework.core.env.Environment;
/**
* @author Dave Syer
*/
@SpringBootApplication
public class BootstrapDecryptionClientApplication implements CommandLineRunner {
private static Log logger = LogFactory.getLog(BootstrapDecryptionClientApplication.class);
@Autowired
private ConfigClientProperties config;
@Autowired
private Environment environment;
@Override
public void run(String... args) throws Exception {
logger.info("Config Server URI: " + config.getUri());
logger.info("Config Server URI: " + this.config.getUri());
logger.info("And info.bar: " + this.environment.getProperty("info.bar"));
logger.info("And info.spam: " + this.environment.getProperty("info.spam"));
}
public static void main(String[] args) {

View File

@@ -1,3 +1,5 @@
spring:
application:
name: client
info:
bar: '{cipher}db63f1b828044c38f9fab4cbe4cd2ad508380399e184691902b3c44a38e5189f'

108
configserver/pom.xml Normal file
View File

@@ -0,0 +1,108 @@
<?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"
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>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-sample-configserver</artifactId>
<version>Brixton.BUILD-SNAPSHOT</version>
<packaging>jar</packaging>
<name>spring-cloud-sample-configserver</name>
<description>Demo project for Spring Cloud</description>
<parent>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-parent</artifactId>
<version>Brixton.BUILD-SNAPSHOT</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<start-class>demo.DemoApplication</start-class>
<java.version>1.7</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<!--skip deploy (this is just a test module) -->
<artifactId>maven-deploy-plugin</artifactId>
<configuration>
<skip>true</skip>
</configuration>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>http://repo.spring.io/libs-snapshot-local</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>http://repo.spring.io/libs-milestone-local</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-releases</id>
<name>Spring Releases</name>
<url>http://repo.spring.io/release</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>

View File

@@ -0,0 +1,15 @@
package demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}

View File

@@ -0,0 +1,19 @@
server:
port: 8888
encrypt:
key: ${SECRET_KEY:foo} # normally this would be an environment variable
spring:
application:
name: configserver
cloud:
config:
server:
bootstrap: true
git:
uri: https://github.com/spring-cloud-samples/config-repo
encrypt:
enabled: false
overrides:
info.bar: '\{cipher}762c11829d517b203ac94a0180f1950b133b83cde34296549d8fed611a9b2fb5'

View File

@@ -0,0 +1,20 @@
package demo;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.SpringApplicationConfiguration;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
@RunWith(SpringJUnit4ClassRunner.class)
@SpringApplicationConfiguration(classes = ConfigServerApplication.class)
@WebAppConfiguration
@DirtiesContext
public class ConfigServerApplicationTests {
@Test
public void contextLoads() {
}
}

View File

@@ -22,6 +22,7 @@
<module>config-client</module>
<module>config-client-decrypt</module>
<module>config-retry</module>
<module>configserver</module>
<module>configserver-bootstrap</module>
<module>configserver-eureka</module>
<module>eureka-first</module>