feat(商城): 添加springboot-admin监控

master
wayn 3 years ago
parent 4b06dabb60
commit c1e48cd923

@ -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>waynboot</artifactId>
<groupId>com.wayn</groupId>
<version>1.1.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>com.wayn.monitor</artifactId>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-server</artifactId>
<version>${spring-boot-admin.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
</project>

@ -0,0 +1,14 @@
package com.wayn;
import de.codecentric.boot.admin.server.config.EnableAdminServer;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableAdminServer
@SpringBootApplication
public class MonitorApplication {
public static void main(String[] args) {
SpringApplication.run(MonitorApplication.class, args);
}
}

@ -0,0 +1,41 @@
package com.wayn.monitor.config;
import de.codecentric.boot.admin.server.config.AdminServerProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
@Configuration
public class WebSecurityConfigurer extends WebSecurityConfigurerAdapter {
private final String adminContextPath;
public WebSecurityConfigurer(AdminServerProperties adminServerProperties) {
this.adminContextPath = adminServerProperties.getContextPath();
}
@Override
protected void configure(HttpSecurity http) throws Exception {
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
successHandler.setTargetUrlParameter("redirectTo");
successHandler.setDefaultTargetUrl(adminContextPath + "/");
http
.headers().frameOptions().disable()
.and().authorizeRequests()
.antMatchers(adminContextPath + "/assets/**"
, adminContextPath + "/login"
, adminContextPath + "/actuator/**"
, adminContextPath + "/instances/**"
).permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage(adminContextPath + "/login")
.successHandler(successHandler).and()
.logout().logoutUrl(adminContextPath + "/logout")
.and()
.httpBasic().and()
.csrf()
.disable();
}
}

@ -0,0 +1,9 @@
server:
port: 89
shutdown: graceful # 优雅关机
spring:
security:
user:
name: user
password: admin123

@ -16,6 +16,7 @@
<module>waynboot-message-consumer</module>
<module>waynboot-message-core</module>
<module>waynboot-data</module>
<module>com.wayn.monitor</module>
</modules>
<groupId>com.wayn</groupId>
<artifactId>waynboot</artifactId>
@ -53,6 +54,7 @@
<jwt.version>3.18.3</jwt.version>
<qiniu.version>7.9.1</qiniu.version>
<mail.version>1.4.7</mail.version>
<spring-boot-admin.version>2.5.4</spring-boot-admin.version>
</properties>
<dependencies>

@ -113,6 +113,11 @@
<version>0.32.0</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring-boot-admin.version}</version>
</dependency>
</dependencies>
<build>

@ -65,7 +65,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
//处理跨域请求中的Preflight请求(cors)设置corsConfigurationSource后无需使用
// .requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
// 对于登录login 验证码captchaImage 允许匿名访问
.antMatchers("/favicon.ico", "/login", "/favicon.ico").anonymous()
.antMatchers("/favicon.ico", "/login", "/favicon.ico", "/actuator/**").anonymous()
.antMatchers("/slider/**").anonymous()
.antMatchers("/captcha/**").anonymous()
.antMatchers("/upload/**").anonymous()

@ -3,6 +3,8 @@ server:
shutdown: graceful # 优雅关机
spring:
application:
name: waynboot-admin-api
profiles:
active: dev,druid,express
thymeleaf:
@ -19,6 +21,11 @@ spring:
jackson:
date-format: yyyy-MM-dd HH:mm:ss
time-zone: GMT+8
boot:
admin:
client:
url: http://localhost:89
# token配置
token:
@ -35,6 +42,20 @@ logging:
com.wayn: debug
org.springframework: info
com.baomidou: info
file:
name: E:/home/${spring.application.name}/info.log
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
logfile:
external-file: ${logging.file.name}
health:
show-details: always
# mybatis plus 配置
mybatis-plus:

@ -77,6 +77,12 @@
<version>${fastjson.version}</version>
</dependency>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring-boot-admin.version}</version>
</dependency>
</dependencies>

@ -2,6 +2,8 @@ server:
port: 85
shutdown: graceful # 优雅关机
spring:
application:
name: waynboot-message-consumer
redis:
host: 127.0.0.1
port: 6379
@ -25,9 +27,27 @@ spring:
acknowledge-mode: manual
direct:
acknowledge-mode: manual
boot:
admin:
client:
url: http://localhost:89
# 日志配置
logging:
level:
com.wayn: debug
org.springframework: info
file:
name: E:/home/${spring.application.name}/info.log
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
logfile:
external-file: ${logging.file.name}
health:
show-details: always

@ -17,6 +17,12 @@
</properties>
<dependencies>
<dependency>
<groupId>de.codecentric</groupId>
<artifactId>spring-boot-admin-starter-client</artifactId>
<version>${spring-boot-admin.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>

@ -11,6 +11,8 @@ server:
#http-port: 82
spring:
application:
name: waynboot-mobile-api
profiles:
active: dev,hikari
thymeleaf:
@ -26,6 +28,10 @@ spring:
max-request-size: 200MB
jackson:
default-property-inclusion: non_null # 接口返回字段值为null的属性不展示
boot:
admin:
client:
url: http://localhost:89
# token配置
token:
@ -42,6 +48,8 @@ logging:
com.wayn: info
org.springframework: info
com.baomidou: info
file:
name: E:/home/${spring.application.name}/info.log
# mybatis plus 配置
mybatis-plus:
@ -82,3 +90,8 @@ management:
web:
exposure:
include: '*'
endpoint:
logfile:
external-file: ${logging.file.name}
health:
show-details: always

Loading…
Cancel
Save