简单集成 spring boot admin ,即 ops 项目

pull/1/head
YunaiV 2019-03-08 01:43:32 +08:00
parent f525e97987
commit 9d46fdf3eb
11 changed files with 88 additions and 4 deletions

View File

@ -92,6 +92,27 @@
<version>1.0-SNAPSHOT</version>
</dependency>
<!--<dependency>-->
<!--<groupId>de.codecentric</groupId>-->
<!--<artifactId>spring-boot-admin-starter-server</artifactId>-->
<!--<version>2.1.3</version>-->
<!--</dependency>-->
<!--<dependency>-->
<!--<groupId>de.codecentric</groupId>-->
<!--<artifactId>spring-boot-admin-server-ui</artifactId>-->
<!--<version>2.1.3</version>-->
<!--</dependency>-->
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
</dependencies>
<build>

View File

@ -2,14 +2,15 @@ package cn.iocoder.mall.admin.application;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
@SpringBootApplication(scanBasePackages = {"cn.iocoder.mall.admin"})
//@EnableAdminServer
public class AdminApplication {
public static void main(String[] args) {
ConfigurableApplicationContext ctx = SpringApplication.run(AdminApplication.class, args);
System.out.println(); // TODO 后面去掉,这里是临时的
SpringApplication.run(AdminApplication.class, args);
// ConfigurableApplicationContext ctx =
// System.out.println(); // TODO 后面去掉,这里是临时的
}
}

View File

@ -26,6 +26,8 @@ public class MVCConfiguration implements WebMvcConfigurer {
.excludePathPatterns("/admins/passport/login"); // 排除登陆接口
}
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
// 解决 swagger-ui.html 的访问,参考自 https://stackoverflow.com/questions/43545540/swagger-ui-no-mapping-found-for-http-request 解决

View File

@ -1,9 +1,19 @@
spring:
application:
name: admin-application
boot:
admin:
client:
url: http://127.0.0.1:8080
# server
server:
port: 18083
servlet:
context-path: /admin-api/
context-path: /admin-api/
management:
endpoints:
web:
exposure:
include: "*"

34
ops/pom.xml Normal file
View File

@ -0,0 +1,34 @@
<?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">
<parent>
<artifactId>mall-parent</artifactId>
<groupId>cn.iocoder.mall</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>ops</artifactId>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-server-ui</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,15 @@
package cn.iocoder.mall.ops;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
@EnableAdminServer
public class OpsApplication {
public static void main(String[] args) {
SpringApplication.run(OpsApplication.class, args);
}
}

View File

@ -19,6 +19,7 @@
<module>user</module>
<module>common</module>
<module>admin</module>
<module>ops</module>
</modules>
<packaging>pom</packaging>