Merge branch 'craedel-spring-cloud-config'
This commit is contained in:
commit
82559f7378
27
spring-cloud-config/README.md
Normal file
27
spring-cloud-config/README.md
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
## Spring Cloud Config ##
|
||||||
|
|
||||||
|
To get this example working, you have to initialize a new *Git* repository in
|
||||||
|
the ```client-config``` directory first *and* you have to set the environment variable
|
||||||
|
```CONFIG_REPO``` to an absolute path of that directory.
|
||||||
|
|
||||||
|
```
|
||||||
|
$> cd client-config
|
||||||
|
$> git init
|
||||||
|
$> git add .
|
||||||
|
$> git commit -m 'Initial commit'
|
||||||
|
$> export CONFIG_REPO=$(pwd)
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you're able to run the examples with ```mvn install spring-boot:run```.
|
||||||
|
|
||||||
|
### Docker ###
|
||||||
|
|
||||||
|
To get the *Docker* examples working, you have to repackage the ```spring-cloud-config-server```
|
||||||
|
and ```spring-cloud-config-client``` modules first:
|
||||||
|
|
||||||
|
```
|
||||||
|
$> mvn install spring-boot:repackage
|
||||||
|
```
|
||||||
|
|
||||||
|
Don't forget to download the *Java JCE* package from
|
||||||
|
(Oracle)[http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html].
|
@ -1,79 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
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>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.baeldung.spring.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-config</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<artifactId>client</artifactId>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<name>client</name>
|
|
||||||
<description>Demo project for Spring Cloud Config Client</description>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
<java.version>1.8</java.version>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-starter-config</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-dependencies</artifactId>
|
|
||||||
<version>Brixton.BUILD-SNAPSHOT</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>spring-snapshots</id>
|
|
||||||
<name>Spring Snapshots</name>
|
|
||||||
<url>https://repo.spring.io/snapshot</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>spring-milestones</id>
|
|
||||||
<name>Spring Milestones</name>
|
|
||||||
<url>https://repo.spring.io/milestone</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
</project>
|
|
@ -1,17 +0,0 @@
|
|||||||
package com.baeldung.spring.cloud.config.client;
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
|
||||||
@SpringApplicationConfiguration(classes = ConfigClient.class)
|
|
||||||
@WebAppConfiguration
|
|
||||||
public class ConfigClientLiveTest {
|
|
||||||
@Test
|
|
||||||
public void contextLoads() {
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,6 +1,6 @@
|
|||||||
FROM alpine-java:base
|
FROM alpine-java:base
|
||||||
MAINTAINER baeldung.com
|
MAINTAINER baeldung.com
|
||||||
RUN apk --no-cache add netcat-openbsd
|
RUN apk --no-cache add netcat-openbsd
|
||||||
COPY files/config-client.jar /opt/spring-cloud/lib/
|
COPY files/spring-cloud-config-client-1.0.0-SNAPSHOT.jar /opt/spring-cloud/lib/config-client.jar
|
||||||
COPY files/config-client-entrypoint.sh /opt/spring-cloud/bin/
|
COPY files/config-client-entrypoint.sh /opt/spring-cloud/bin/
|
||||||
RUN chmod 755 /opt/spring-cloud/bin/config-client-entrypoint.sh
|
RUN chmod 755 /opt/spring-cloud/bin/config-client-entrypoint.sh
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
FROM alpine-java:base
|
FROM alpine-java:base
|
||||||
MAINTAINER baeldung.com
|
MAINTAINER baeldung.com
|
||||||
COPY files/config-server.jar /opt/spring-cloud/lib/
|
COPY files/spring-cloud-config-server-1.0.0-SNAPSHOT.jar /opt/spring-cloud/lib/config-server.jar
|
||||||
ENV SPRING_APPLICATION_JSON='{"spring": {"cloud": {"config": {"server": \
|
ENV SPRING_APPLICATION_JSON='{"spring": {"cloud": {"config": {"server": \
|
||||||
{"git": {"uri": "/var/lib/spring-cloud/config-repo", "clone-on-start": true}}}}}}'
|
{"git": {"uri": "/var/lib/spring-cloud/config-repo", "clone-on-start": true}}}}}}'
|
||||||
ENTRYPOINT ["/usr/bin/java"]
|
ENTRYPOINT ["/usr/bin/java"]
|
||||||
|
2
spring-cloud-config/docker/files/.gitignore
vendored
Normal file
2
spring-cloud-config/docker/files/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
/UnlimitedJCEPolicyJDK8
|
||||||
|
/*.jar
|
@ -5,38 +5,48 @@
|
|||||||
|
|
||||||
<groupId>com.baeldung.spring.cloud</groupId>
|
<groupId>com.baeldung.spring.cloud</groupId>
|
||||||
<artifactId>spring-cloud-config</artifactId>
|
<artifactId>spring-cloud-config</artifactId>
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
<module>server</module>
|
<module>spring-cloud-config-server</module>
|
||||||
<module>client</module>
|
<module>spring-cloud-config-client</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>spring-boot-starter-parent</artifactId>
|
<artifactId>parent-modules</artifactId>
|
||||||
<version>1.3.5.RELEASE</version>
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
<relativePath>..</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
<dependencyManagement>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-parent</artifactId>
|
||||||
|
<version>1.4.0.RELEASE</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-dependencies</artifactId>
|
||||||
|
<version>Brixton.SR4</version>
|
||||||
|
<type>pom</type>
|
||||||
|
<scope>import</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</dependencyManagement>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<pluginManagement>
|
||||||
<plugin>
|
<plugins>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<plugin>
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<version>${maven-surefire-plugin.version}</version>
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
<configuration>
|
<version>1.4.0.RELEASE</version>
|
||||||
<excludes>
|
</plugin>
|
||||||
<exclude>**/*LiveTest.java</exclude>
|
</plugins>
|
||||||
</excludes>
|
</pluginManagement>
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
</plugins>
|
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<org.springframework.boot.version>1.3.5.RELEASE</org.springframework.boot.version>
|
|
||||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
|
||||||
</properties>
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
|
||||||
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>
|
|
||||||
|
|
||||||
<parent>
|
|
||||||
<groupId>com.baeldung.spring.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-config</artifactId>
|
|
||||||
<version>0.0.1-SNAPSHOT</version>
|
|
||||||
</parent>
|
|
||||||
<artifactId>server</artifactId>
|
|
||||||
|
|
||||||
<name>server</name>
|
|
||||||
<description>Demo project for Spring Cloud Config Server</description>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
|
||||||
<java.version>1.8</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-security</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-test</artifactId>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
<dependencyManagement>
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
|
||||||
<artifactId>spring-cloud-dependencies</artifactId>
|
|
||||||
<version>Brixton.BUILD-SNAPSHOT</version>
|
|
||||||
<type>pom</type>
|
|
||||||
<scope>import</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</dependencyManagement>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>spring-snapshots</id>
|
|
||||||
<name>Spring Snapshots</name>
|
|
||||||
<url>https://repo.spring.io/snapshot</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>true</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
<repository>
|
|
||||||
<id>spring-milestones</id>
|
|
||||||
<name>Spring Milestones</name>
|
|
||||||
<url>https://repo.spring.io/milestone</url>
|
|
||||||
<snapshots>
|
|
||||||
<enabled>false</enabled>
|
|
||||||
</snapshots>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
</project>
|
|
@ -1,18 +0,0 @@
|
|||||||
package com.baeldung.spring.cloud.config.server;
|
|
||||||
|
|
||||||
import org.junit.Ignore;
|
|
||||||
import org.junit.Test;
|
|
||||||
import org.junit.runner.RunWith;
|
|
||||||
import org.springframework.boot.test.SpringApplicationConfiguration;
|
|
||||||
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
|
||||||
import org.springframework.test.context.web.WebAppConfiguration;
|
|
||||||
|
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
|
||||||
@SpringApplicationConfiguration(classes = ConfigServer.class)
|
|
||||||
@WebAppConfiguration
|
|
||||||
@Ignore
|
|
||||||
public class ConfigServerListTest {
|
|
||||||
@Test
|
|
||||||
public void contextLoads() {
|
|
||||||
}
|
|
||||||
}
|
|
40
spring-cloud-config/spring-cloud-config-client/pom.xml
Normal file
40
spring-cloud-config/spring-cloud-config-client/pom.xml
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
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>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung.spring.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-config</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>spring-cloud-config-client</artifactId>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>spring-cloud-config-client</name>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-starter-config</artifactId>
|
||||||
|
<version>1.1.3.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<version>1.4.0.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>../docker/files</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -1,5 +1,5 @@
|
|||||||
spring.application.name=config-client
|
spring.application.name=config-client
|
||||||
spring.profiles.active=development
|
spring.profiles.active=development
|
||||||
spring.cloud.config.uri=http://localhost:8888
|
spring.cloud.config.uri=http://localhost:${PORT:8888}
|
||||||
spring.cloud.config.username=root
|
spring.cloud.config.username=root
|
||||||
spring.cloud.config.password=s3cr3t
|
spring.cloud.config.password=s3cr3t
|
44
spring-cloud-config/spring-cloud-config-server/pom.xml
Normal file
44
spring-cloud-config/spring-cloud-config-server/pom.xml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
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>
|
||||||
|
|
||||||
|
<parent>
|
||||||
|
<groupId>com.baeldung.spring.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-config</artifactId>
|
||||||
|
<version>1.0.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
<artifactId>spring-cloud-config-server</artifactId>
|
||||||
|
|
||||||
|
<name>spring-cloud-config-server</name>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-config-server</artifactId>
|
||||||
|
<version>1.1.3.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-security</artifactId>
|
||||||
|
<version>1.4.0.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-web</artifactId>
|
||||||
|
<version>1.4.0.RELEASE</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<outputDirectory>../docker/files</outputDirectory>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -1,6 +1,7 @@
|
|||||||
server.port=8888
|
server.port=${PORT:8888}
|
||||||
spring.cloud.config.server.git.uri=https://github.com/eugenp/tutorials/tree/master/spring-cloud-config/client-config
|
spring.cloud.config.server.git.uri=${CONFIG_REPO}
|
||||||
spring.cloud.config.server.git.clone-on-start=false
|
spring.cloud.config.server.git.clone-on-start=false
|
||||||
|
spring.cloud.config.fail-fast=true
|
||||||
security.user.name=root
|
security.user.name=root
|
||||||
security.user.password=s3cr3t
|
security.user.password=s3cr3t
|
||||||
encrypt.key-store.location=classpath:/config-server.jks
|
encrypt.key-store.location=classpath:/config-server.jks
|
Loading…
x
Reference in New Issue
Block a user