diff --git a/spring-boot-demo-admin-client/.gitignore b/spring-boot-demo-admin-client/.gitignore new file mode 100644 index 0000000..82eca33 --- /dev/null +++ b/spring-boot-demo-admin-client/.gitignore @@ -0,0 +1,25 @@ +/target/ +!.mvn/wrapper/maven-wrapper.jar + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/build/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ \ No newline at end of file diff --git a/spring-boot-demo-admin-client/README.md b/spring-boot-demo-admin-client/README.md new file mode 100644 index 0000000..7ab5730 --- /dev/null +++ b/spring-boot-demo-admin-client/README.md @@ -0,0 +1,119 @@ +# spring-boot-demo-admin-client + +> 本 demo 主要演示了普通项目如何集成 Spring Boot Admin,并把自己的运行状态交给 Spring Boot Admin 进行展现。 + +## pom.xml + +```xml + + + 4.0.0 + + com.xkcoding + spring-boot-demo-admin-client + 0.0.1-SNAPSHOT + jar + + spring-boot-demo-admin-client + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 2.0.5.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + 2.0.3 + + + + + org.springframework.boot + spring-boot-starter-web + + + + de.codecentric + spring-boot-admin-starter-client + + + + org.springframework.boot + spring-boot-starter-security + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + de.codecentric + spring-boot-admin-dependencies + ${spring-boot-admin.version} + pom + import + + + + + + spring-boot-demo-admin-client + + + org.springframework.boot + spring-boot-maven-plugin + + + + + +``` + +## application.yml + +```yaml +server: + port: 8080 + servlet: + context-path: /demo +spring: + application: + # Spring Boot Admin展示的客户端项目名,不设置,会使用自动生成的随机id + name: spring-boot-demo-admin-client + boot: + admin: + client: + # Spring Boot Admin 服务端地址 + url: "http://localhost:8000/admin" + instance: + metadata: + # 客户端端点信息的安全认证信息 + user.name: ${spring.security.user.name} + user.password: ${spring.security.user.password} + security: + user: + name: xkcoding + password: 123456 +management: + endpoint: + health: + # 端点健康情况,默认值"never",设置为"always"可以显示硬盘使用情况和线程情况 + show-details: always + endpoints: + web: + exposure: + # 设置端点暴露的哪些内容,默认["health","info"],设置"*"代表暴露所有可访问的端点 + include: "*" +``` + diff --git a/spring-boot-demo-admin-client/pom.xml b/spring-boot-demo-admin-client/pom.xml new file mode 100644 index 0000000..7cc2508 --- /dev/null +++ b/spring-boot-demo-admin-client/pom.xml @@ -0,0 +1,73 @@ + + + 4.0.0 + + com.xkcoding + spring-boot-demo-admin-client + 0.0.1-SNAPSHOT + jar + + spring-boot-demo-admin-client + Demo project for Spring Boot + + + org.springframework.boot + spring-boot-starter-parent + 2.0.5.RELEASE + + + + + UTF-8 + UTF-8 + 1.8 + 2.0.3 + + + + + org.springframework.boot + spring-boot-starter-web + + + + de.codecentric + spring-boot-admin-starter-client + + + + org.springframework.boot + spring-boot-starter-security + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + + + de.codecentric + spring-boot-admin-dependencies + ${spring-boot-admin.version} + pom + import + + + + + + spring-boot-demo-admin-client + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/spring-boot-demo-admin-client/src/main/java/com/xkcoding/admin/client/SpringBootDemoAdminClientApplication.java b/spring-boot-demo-admin-client/src/main/java/com/xkcoding/admin/client/SpringBootDemoAdminClientApplication.java new file mode 100644 index 0000000..0b3527b --- /dev/null +++ b/spring-boot-demo-admin-client/src/main/java/com/xkcoding/admin/client/SpringBootDemoAdminClientApplication.java @@ -0,0 +1,25 @@ +package com.xkcoding.admin.client; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +/** + *

+ * 启动类 + *

+ * + * @package: com.xkcoding.admin.client + * @description: 启动类 + * @author: yangkai.shen + * @date: Created in 2018/10/8 2:16 PM + * @copyright: Copyright (c) 2018 + * @version: V1.0 + * @modified: yangkai.shen + */ +@SpringBootApplication +public class SpringBootDemoAdminClientApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBootDemoAdminClientApplication.class, args); + } +} diff --git a/spring-boot-demo-admin-client/src/main/java/com/xkcoding/admin/client/controller/IndexController.java b/spring-boot-demo-admin-client/src/main/java/com/xkcoding/admin/client/controller/IndexController.java new file mode 100644 index 0000000..3fd383f --- /dev/null +++ b/spring-boot-demo-admin-client/src/main/java/com/xkcoding/admin/client/controller/IndexController.java @@ -0,0 +1,25 @@ +package com.xkcoding.admin.client.controller; + +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + *

+ * 首页 + *

+ * + * @package: com.xkcoding.admin.client.controller + * @description: 首页 + * @author: yangkai.shen + * @date: Created in 2018/10/8 2:15 PM + * @copyright: Copyright (c) 2018 + * @version: V1.0 + * @modified: yangkai.shen + */ +@RestController +public class IndexController { + @GetMapping(value = {"", "/"}) + public String index() { + return "This is a Spring Boot Admin Client."; + } +} diff --git a/spring-boot-demo-admin-client/src/main/resources/application.yml b/spring-boot-demo-admin-client/src/main/resources/application.yml new file mode 100644 index 0000000..fd32c12 --- /dev/null +++ b/spring-boot-demo-admin-client/src/main/resources/application.yml @@ -0,0 +1,32 @@ +server: + port: 8080 + servlet: + context-path: /demo +spring: + application: + # Spring Boot Admin展示的客户端项目名,不设置,会使用自动生成的随机id + name: spring-boot-demo-admin-client + boot: + admin: + client: + # Spring Boot Admin 服务端地址 + url: "http://localhost:8000/admin" + instance: + metadata: + # 客户端端点信息的安全认证信息 + user.name: ${spring.security.user.name} + user.password: ${spring.security.user.password} + security: + user: + name: xkcoding + password: 123456 +management: + endpoint: + health: + # 端点健康情况,默认值"never",设置为"always"可以显示硬盘使用情况和线程情况 + show-details: always + endpoints: + web: + exposure: + # 设置端点暴露的哪些内容,默认["health","info"],设置"*"代表暴露所有可访问的端点 + include: "*" \ No newline at end of file diff --git a/spring-boot-demo-admin-client/src/test/java/com/xkcoding/admin/client/SpringBootDemoAdminClientApplicationTests.java b/spring-boot-demo-admin-client/src/test/java/com/xkcoding/admin/client/SpringBootDemoAdminClientApplicationTests.java new file mode 100644 index 0000000..41b8cf8 --- /dev/null +++ b/spring-boot-demo-admin-client/src/test/java/com/xkcoding/admin/client/SpringBootDemoAdminClientApplicationTests.java @@ -0,0 +1,16 @@ +package com.xkcoding.admin.client; + +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 SpringBootDemoAdminClientApplicationTests { + + @Test + public void contextLoads() { + } + +}