From c6d989947faab3fd63bdb7c1fd3b72dbfd83a9fc Mon Sep 17 00:00:00 2001
From: "yangkai.shen" <237497819@qq.com>
Date: Tue, 21 Nov 2017 16:16:28 +0800
Subject: [PATCH] =?UTF-8?q?spring=20boot=20=E9=9B=86=E6=88=90=20spring=20b?=
=?UTF-8?q?oot=20admin=20=E8=BF=9B=E8=A1=8C=E5=8F=AF=E8=A7=86=E5=8C=96?=
=?UTF-8?q?=E7=9B=91=E6=8E=A7?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
README.md | 2 +
spring-boot-demo-actuator/README.md | 4 +-
spring-boot-demo-admin/README.md | 103 +++++++++++++++++++++
spring-boot-demo-admin/pom.xml | 48 ++++++++++
.../SpringBootDemoAdminApplication.java | 28 ++++++
.../src/main/resources/application.yml | 17 ++++
.../SpringBootDemoAdminApplicationTests.java | 16 ++++
spring-boot-demo-cache-redis/README.md | 2 +-
spring-boot-demo-helloworld/README.md | 2 +-
spring-boot-demo-logback/README.md | 2 +-
spring-boot-demo-orm-jpa/README.md | 2 +-
spring-boot-demo-orm-mybatis/README.md | 2 +-
spring-boot-demo-parent/pom.xml | 1 +
spring-boot-demo-properties/README.md | 2 +-
spring-boot-demo-swagger/README.md | 2 +-
15 files changed, 224 insertions(+), 9 deletions(-)
create mode 100644 spring-boot-demo-admin/README.md
create mode 100644 spring-boot-demo-admin/pom.xml
create mode 100644 spring-boot-demo-admin/src/main/java/com/xkcoding/springbootdemoadmin/SpringBootDemoAdminApplication.java
create mode 100644 spring-boot-demo-admin/src/main/resources/application.yml
create mode 100644 spring-boot-demo-admin/src/test/java/com/xkcoding/springbootdemoadmin/SpringBootDemoAdminApplicationTests.java
diff --git a/README.md b/README.md
index 31c463d..fddc5d8 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,7 @@ spring boot demo 是一个用来学习 spring boot 的项目,已经集成 actu
../spring-boot-demo-helloworld
../spring-boot-demo-properties
../spring-boot-demo-actuator
+ ../spring-boot-demo-admin
../spring-boot-demo-logback
../spring-boot-demo-orm-jpa
../spring-boot-demo-orm-mybatis
@@ -143,6 +144,7 @@ spring boot demo 是一个用来学习 spring boot 的项目,已经集成 actu
| [spring-boot-demo-helloworld](./spring-boot-demo-helloworld) | spring-boot 的一个 helloworld |
| [spring-boot-demo-properties](./spring-boot-demo-properties) | spring-boot 读取配置文件中的内容 |
| [spring-boot-demo-actuator](./spring-boot-demo-actuator) | spring-boot 集成 spring-boot-starter-actuator 用于监控 spring-boot 的启动和运行状态 |
+| [spring-boot-demo-admin](./spring-boot-demo-admin) | spring-boot 集成 spring-boot-admin 来可视化的监控 spring-boot 程序的运行状态,可以与 actuator 互相搭配使用 |
| [spring-boot-demo-logback](./spring-boot-demo-logback) | spring-boot 集成 logback 日志 |
| [spring-boot-demo-orm-jpa](./spring-boot-demo-orm-jpa) | spring-boot 集成 spring-boot-starter-data-jpa 操作数据库 |
| [spring-boot-demo-orm-mybatis](./spring-boot-demo-orm-mybatis) | spring-boot 集成 [mybatis-spring-boot-starter](https://github.com/mybatis/spring-boot-starter)、[mybatis-spring-boot-starter](https://github.com/alibaba/druid/tree/master/druid-spring-boot-starter) |
diff --git a/spring-boot-demo-actuator/README.md b/spring-boot-demo-actuator/README.md
index 3852855..3b410e2 100644
--- a/spring-boot-demo-actuator/README.md
+++ b/spring-boot-demo-actuator/README.md
@@ -75,7 +75,7 @@ management:
#### 方法一:(本 demo 中使用的是这种)
-```yml
+```yaml
management:
security:
enabled: false
@@ -94,7 +94,7 @@ pom.xml 中添加以下 `spring-boot-starter-security` 依赖:
并在 `application.yml` 文件中设置访问的密码
-```yml
+```yaml
security:
basic:
enabled: true
diff --git a/spring-boot-demo-admin/README.md b/spring-boot-demo-admin/README.md
new file mode 100644
index 0000000..3c53d81
--- /dev/null
+++ b/spring-boot-demo-admin/README.md
@@ -0,0 +1,103 @@
+# spring-boot-demo-admin
+
+依赖[spring-boot-demo-parent](../spring-boot-demo-parent)、服务端依赖 `spring-boot-demo-admin` 和 `spring-boot-admin-server-ui`、客户端依赖 `spring-boot-admin-starter-client`
+
+### pom.xml
+
+```xml
+
+
+ 4.0.0
+
+ spring-boot-demo-admin
+ 0.0.1-SNAPSHOT
+ war
+
+ spring-boot-demo-admin
+ Demo project for Spring Boot
+
+
+ com.xkcoding
+ spring-boot-demo-parent
+ 0.0.1-SNAPSHOT
+ ../spring-boot-demo-parent/pom.xml
+
+
+
+ 1.5.2
+ 1.5.2
+ 1.5.2
+
+
+
+
+ de.codecentric
+ spring-boot-admin-server
+ ${admin.server.version}
+
+
+ de.codecentric
+ spring-boot-admin-server-ui
+ ${admin.server.ui.version}
+
+
+ de.codecentric
+ spring-boot-admin-starter-client
+ ${admin.client.version}
+
+
+
+
+ spring-boot-demo-admin
+
+
+
+```
+
+### application.yml
+
+```yaml
+server:
+ port: 8080
+ context-path: /demo
+spring:
+ application:
+ # 可视化管控台展示的监控项目名,不设置,会使用自动生成的名字
+ name: Spring Boot Admin
+ boot:
+ admin:
+ # 可视化管控台界面的 context-path
+ context-path: /spa
+ url: http://localhost:${server.port}/${server.context-path}
+ jackson:
+ serialization: true
+# 去除权限校验
+endpoints:
+ sensitive: false
+```
+
+### SpringBootDemoAdminApplication.java
+
+```java
+@SpringBootApplication
+@EnableAdminServer // 开启管控台
+@RestController
+public class SpringBootDemoAdminApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringBootDemoAdminApplication.class, args);
+ }
+
+ @GetMapping("/")
+ public Map index() {
+ ConcurrentMap ret = Maps.newConcurrentMap();
+ ret.put("msg", "Hello Spring Boot Admin");
+ return ret;
+ }
+}
+```
+
+### 访问
+
+http://localhost:8080/demo/spa 即可查看管控台主页,点击项目的 `Detail` 即可查看详细信息,但是比起 `actuator` 提供的端点监控,看起来确实美观不少,但是都各有优缺点。
\ No newline at end of file
diff --git a/spring-boot-demo-admin/pom.xml b/spring-boot-demo-admin/pom.xml
new file mode 100644
index 0000000..056cb87
--- /dev/null
+++ b/spring-boot-demo-admin/pom.xml
@@ -0,0 +1,48 @@
+
+
+ 4.0.0
+
+ spring-boot-demo-admin
+ 0.0.1-SNAPSHOT
+ war
+
+ spring-boot-demo-admin
+ Demo project for Spring Boot
+
+
+ com.xkcoding
+ spring-boot-demo-parent
+ 0.0.1-SNAPSHOT
+ ../spring-boot-demo-parent/pom.xml
+
+
+
+ 1.5.2
+ 1.5.2
+ 1.5.2
+
+
+
+
+ de.codecentric
+ spring-boot-admin-server
+ ${admin.server.version}
+
+
+ de.codecentric
+ spring-boot-admin-server-ui
+ ${admin.server.ui.version}
+
+
+ de.codecentric
+ spring-boot-admin-starter-client
+ ${admin.client.version}
+
+
+
+
+ spring-boot-demo-admin
+
+
+
\ No newline at end of file
diff --git a/spring-boot-demo-admin/src/main/java/com/xkcoding/springbootdemoadmin/SpringBootDemoAdminApplication.java b/spring-boot-demo-admin/src/main/java/com/xkcoding/springbootdemoadmin/SpringBootDemoAdminApplication.java
new file mode 100644
index 0000000..1200964
--- /dev/null
+++ b/spring-boot-demo-admin/src/main/java/com/xkcoding/springbootdemoadmin/SpringBootDemoAdminApplication.java
@@ -0,0 +1,28 @@
+package com.xkcoding.springbootdemoadmin;
+
+import com.google.common.collect.Maps;
+import de.codecentric.boot.admin.config.EnableAdminServer;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.Map;
+import java.util.concurrent.ConcurrentMap;
+
+@SpringBootApplication
+@EnableAdminServer // 开启管控台
+@RestController
+public class SpringBootDemoAdminApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(SpringBootDemoAdminApplication.class, args);
+ }
+
+ @GetMapping("/")
+ public Map index() {
+ ConcurrentMap ret = Maps.newConcurrentMap();
+ ret.put("msg", "Hello Spring Boot Admin");
+ return ret;
+ }
+}
diff --git a/spring-boot-demo-admin/src/main/resources/application.yml b/spring-boot-demo-admin/src/main/resources/application.yml
new file mode 100644
index 0000000..20bc0a9
--- /dev/null
+++ b/spring-boot-demo-admin/src/main/resources/application.yml
@@ -0,0 +1,17 @@
+server:
+ port: 8080
+ context-path: /demo
+spring:
+ application:
+ # 可视化管控台展示的监控项目名,不设置,会使用自动生成的名字
+ name: Spring Boot Admin
+ boot:
+ admin:
+ # 可视化管控台界面的 context-path
+ context-path: /spa
+ url: http://localhost:${server.port}/${server.context-path}
+ jackson:
+ serialization: true
+# 去除权限校验
+endpoints:
+ sensitive: false
\ No newline at end of file
diff --git a/spring-boot-demo-admin/src/test/java/com/xkcoding/springbootdemoadmin/SpringBootDemoAdminApplicationTests.java b/spring-boot-demo-admin/src/test/java/com/xkcoding/springbootdemoadmin/SpringBootDemoAdminApplicationTests.java
new file mode 100644
index 0000000..053981a
--- /dev/null
+++ b/spring-boot-demo-admin/src/test/java/com/xkcoding/springbootdemoadmin/SpringBootDemoAdminApplicationTests.java
@@ -0,0 +1,16 @@
+package com.xkcoding.springbootdemoadmin;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.test.context.junit4.SpringRunner;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest
+public class SpringBootDemoAdminApplicationTests {
+
+ @Test
+ public void contextLoads() {
+ }
+
+}
diff --git a/spring-boot-demo-cache-redis/README.md b/spring-boot-demo-cache-redis/README.md
index 4671681..a49d3bc 100644
--- a/spring-boot-demo-cache-redis/README.md
+++ b/spring-boot-demo-cache-redis/README.md
@@ -40,7 +40,7 @@
### application.yml
-```yml
+```yaml
server:
port: 8080
context-path: /demo
diff --git a/spring-boot-demo-helloworld/README.md b/spring-boot-demo-helloworld/README.md
index b180f97..47e2096 100644
--- a/spring-boot-demo-helloworld/README.md
+++ b/spring-boot-demo-helloworld/README.md
@@ -67,7 +67,7 @@ public class SpringBootDemoHelloworldApplication {
### application.yml
-```yml
+```yaml
server:
port: 8080
context-path: /demo
diff --git a/spring-boot-demo-logback/README.md b/spring-boot-demo-logback/README.md
index 3050b68..0b67598 100644
--- a/spring-boot-demo-logback/README.md
+++ b/spring-boot-demo-logback/README.md
@@ -58,7 +58,7 @@ public class SpringBootDemoLogbackApplication {
### application.yml
-```yml
+```yaml
server:
port: 8080
context-path: /demo
diff --git a/spring-boot-demo-orm-jpa/README.md b/spring-boot-demo-orm-jpa/README.md
index fee571e..6f2c4fc 100644
--- a/spring-boot-demo-orm-jpa/README.md
+++ b/spring-boot-demo-orm-jpa/README.md
@@ -49,7 +49,7 @@
### application.yml
-```yml
+```yaml
server:
port: 8080
context-path: /demo
diff --git a/spring-boot-demo-orm-mybatis/README.md b/spring-boot-demo-orm-mybatis/README.md
index bc6776c..c6f8c31 100644
--- a/spring-boot-demo-orm-mybatis/README.md
+++ b/spring-boot-demo-orm-mybatis/README.md
@@ -67,7 +67,7 @@
### application.yml
-```yml
+```yaml
server:
port: 8080
context-path: /demo
diff --git a/spring-boot-demo-parent/pom.xml b/spring-boot-demo-parent/pom.xml
index 2333b41..22e187b 100644
--- a/spring-boot-demo-parent/pom.xml
+++ b/spring-boot-demo-parent/pom.xml
@@ -15,6 +15,7 @@
../spring-boot-demo-helloworld
../spring-boot-demo-properties
../spring-boot-demo-actuator
+ ../spring-boot-demo-admin
../spring-boot-demo-logback
../spring-boot-demo-orm-jpa
../spring-boot-demo-orm-mybatis
diff --git a/spring-boot-demo-properties/README.md b/spring-boot-demo-properties/README.md
index cc5fcbd..29a8e0e 100644
--- a/spring-boot-demo-properties/README.md
+++ b/spring-boot-demo-properties/README.md
@@ -4,7 +4,7 @@
### application.yml
-```yml
+```yaml
server:
port: 8080
context-path: /demo
diff --git a/spring-boot-demo-swagger/README.md b/spring-boot-demo-swagger/README.md
index 0811175..37b4baa 100644
--- a/spring-boot-demo-swagger/README.md
+++ b/spring-boot-demo-swagger/README.md
@@ -45,7 +45,7 @@
### application.yml
-```yml
+```yaml
server:
port: 8080
context-path: /demo