Skip to content

Commit 57a3ce9

Browse files
committed
add config-server config-sercurity-server config-client
1 parent 201392e commit 57a3ce9

23 files changed

Lines changed: 617 additions & 0 deletions

File tree

config-client/.gitignore

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
HELP.md
2+
target/
3+
!.mvn/wrapper/maven-wrapper.jar
4+
!**/src/main/**
5+
!**/src/test/**
6+
7+
### STS ###
8+
.apt_generated
9+
.classpath
10+
.factorypath
11+
.project
12+
.settings
13+
.springBeans
14+
.sts4-cache
15+
16+
### IntelliJ IDEA ###
17+
.idea
18+
*.iws
19+
*.iml
20+
*.ipr
21+
22+
### NetBeans ###
23+
/nbproject/private/
24+
/nbbuild/
25+
/dist/
26+
/nbdist/
27+
/.nb-gradle/
28+
build/
29+
30+
### VS Code ###
31+
.vscode/

config-client/pom.xml

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<parent>
6+
<groupId>org.springframework.boot</groupId>
7+
<artifactId>spring-boot-starter-parent</artifactId>
8+
<version>2.1.7.RELEASE</version>
9+
<relativePath/> <!-- lookup parent from repository -->
10+
</parent>
11+
<groupId>com.macro.cloud</groupId>
12+
<artifactId>config-client</artifactId>
13+
<version>0.0.1-SNAPSHOT</version>
14+
<name>config-client</name>
15+
<description>Demo project for Spring Boot</description>
16+
17+
<properties>
18+
<java.version>1.8</java.version>
19+
<spring-cloud.version>Greenwich.SR2</spring-cloud.version>
20+
</properties>
21+
22+
<dependencies>
23+
<dependency>
24+
<groupId>org.springframework.cloud</groupId>
25+
<artifactId>spring-cloud-starter-config</artifactId>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.springframework.cloud</groupId>
29+
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
30+
</dependency>
31+
<dependency>
32+
<groupId>org.springframework.boot</groupId>
33+
<artifactId>spring-boot-starter-web</artifactId>
34+
</dependency>
35+
<dependency>
36+
<groupId>org.springframework.boot</groupId>
37+
<artifactId>spring-boot-starter-actuator</artifactId>
38+
</dependency>
39+
<!--使用消息总线刷新配置时添加-->
40+
<!--<dependency>-->
41+
<!--<groupId>org.springframework.cloud</groupId>-->
42+
<!--<artifactId>spring-cloud-starter-bus-amqp</artifactId>-->
43+
<!--</dependency>-->
44+
45+
<dependency>
46+
<groupId>org.springframework.boot</groupId>
47+
<artifactId>spring-boot-starter-test</artifactId>
48+
<scope>test</scope>
49+
</dependency>
50+
</dependencies>
51+
52+
<dependencyManagement>
53+
<dependencies>
54+
<dependency>
55+
<groupId>org.springframework.cloud</groupId>
56+
<artifactId>spring-cloud-dependencies</artifactId>
57+
<version>${spring-cloud.version}</version>
58+
<type>pom</type>
59+
<scope>import</scope>
60+
</dependency>
61+
</dependencies>
62+
</dependencyManagement>
63+
64+
<build>
65+
<plugins>
66+
<plugin>
67+
<groupId>org.springframework.boot</groupId>
68+
<artifactId>spring-boot-maven-plugin</artifactId>
69+
</plugin>
70+
</plugins>
71+
</build>
72+
73+
</project>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package com.macro.cloud;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
6+
7+
@EnableDiscoveryClient
8+
@SpringBootApplication
9+
public class ConfigClientApplication {
10+
11+
public static void main(String[] args) {
12+
SpringApplication.run(ConfigClientApplication.class, args);
13+
}
14+
15+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package com.macro.cloud.controller;
2+
3+
import org.springframework.beans.factory.annotation.Value;
4+
import org.springframework.cloud.context.config.annotation.RefreshScope;
5+
import org.springframework.web.bind.annotation.GetMapping;
6+
import org.springframework.web.bind.annotation.RestController;
7+
8+
/**
9+
* Created by macro on 2019/9/11.
10+
*/
11+
@RestController
12+
@RefreshScope
13+
public class ConfigClientController {
14+
15+
@Value("${config.info}")
16+
private String configInfo;
17+
18+
@GetMapping("/configInfo")
19+
public String getConfigInfo() {
20+
return configInfo;
21+
}
22+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
server:
2+
port: 9004
3+
spring:
4+
application:
5+
name: config-client
6+
cloud:
7+
config:
8+
profile: dev #启用环境名称
9+
label: dev #分支名称
10+
name: config #配置文件名称
11+
discovery:
12+
enabled: true
13+
service-id: config-server
14+
rabbitmq:
15+
host: localhost
16+
port: 5672
17+
username: guest
18+
password: guest
19+
eureka:
20+
client:
21+
service-url:
22+
defaultZone: http://localhost:8001/eureka/
23+
management:
24+
endpoints:
25+
web:
26+
exposure:
27+
include: 'refresh'
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
server:
2+
port: 9005
3+
spring:
4+
application:
5+
name: config-client
6+
cloud:
7+
config:
8+
profile: dev #启用环境名称
9+
label: dev #分支名称
10+
name: config #配置文件名称
11+
discovery:
12+
enabled: true
13+
service-id: config-server
14+
rabbitmq:
15+
host: localhost
16+
port: 5672
17+
username: guest
18+
password: guest
19+
eureka:
20+
client:
21+
service-url:
22+
defaultZone: http://localhost:8001/eureka/
23+
management:
24+
endpoints:
25+
web:
26+
exposure:
27+
include: 'refresh'
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
server:
2+
port: 9003
3+
spring:
4+
application:
5+
name: config-client
6+
cloud:
7+
config:
8+
profile: dev #启用环境名称
9+
label: dev #分支名称
10+
name: config #配置文件名称
11+
discovery:
12+
enabled: true
13+
service-id: config-server
14+
eureka:
15+
client:
16+
service-url:
17+
defaultZone: http://localhost:8001/eureka/
18+
management:
19+
endpoints:
20+
web:
21+
exposure:
22+
include: 'refresh'
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
server:
2+
port: 9002
3+
spring:
4+
application:
5+
name: config-client
6+
cloud:
7+
config:
8+
profile: dev #启用配置后缀名称
9+
label: dev #分支名称
10+
uri: http://localhost:8905 #配置中心地址
11+
name: config #配置文件名称
12+
username: macro
13+
password: 123456
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
server:
2+
port: 9001
3+
spring:
4+
application:
5+
name: config-client
6+
cloud:
7+
config: #Config客户端配置
8+
profile: dev #启用配置后缀名称
9+
label: dev #分支名称
10+
uri: http://localhost:8901 #配置中心地址
11+
name: config #配置文件名称
12+
eureka:
13+
client:
14+
service-url:
15+
defaultZone: http://localhost:8001/eureka/
16+
management:
17+
endpoints:
18+
web:
19+
exposure:
20+
include: 'refresh'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.macro.cloud;
2+
3+
import org.junit.Test;
4+
import org.junit.runner.RunWith;
5+
import org.springframework.boot.test.context.SpringBootTest;
6+
import org.springframework.test.context.junit4.SpringRunner;
7+
8+
@RunWith(SpringRunner.class)
9+
@SpringBootTest
10+
public class ConfigClientApplicationTests {
11+
12+
@Test
13+
public void contextLoads() {
14+
}
15+
16+
}

0 commit comments

Comments
 (0)