初始化项目
This commit is contained in:
20
xtools-app-monitor/pom.xml
Normal file
20
xtools-app-monitor/pom.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.xujun</groupId>
|
||||
<artifactId>xtools-app</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<packaging>pom</packaging>
|
||||
<artifactId>xtools-app-monitor</artifactId>
|
||||
|
||||
<!-- 子模块 -->
|
||||
<modules>
|
||||
<module>xtools-app-monitor-boot</module>
|
||||
<module>xtools-app-monitor-client</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
10
xtools-app-monitor/xtools-app-monitor-boot/Dockerfile
Normal file
10
xtools-app-monitor/xtools-app-monitor-boot/Dockerfile
Normal file
@@ -0,0 +1,10 @@
|
||||
FROM registry.cn-hangzhou.aliyuncs.com/xujun-public/liberica-openjdk-rocky:25.0.1-11
|
||||
MAINTAINER org.xujun
|
||||
|
||||
ENV JVM_OPTS=""
|
||||
|
||||
RUN /bin/cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && echo 'Asia/Shanghai' >/etc/timezone
|
||||
WORKDIR /data0/app
|
||||
COPY target/xtools-app-monitor-boot-1.0.0.jar /data0/app/xtools-app-monitor-boot.jar
|
||||
|
||||
ENTRYPOINT ["/bin/sh", "-c", "java ${JVM_OPTS} -jar /data0/app/xtools-app-monitor-boot.jar"]
|
||||
60
xtools-app-monitor/xtools-app-monitor-boot/pom.xml
Normal file
60
xtools-app-monitor/xtools-app-monitor-boot/pom.xml
Normal file
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.xujun</groupId>
|
||||
<artifactId>xtools-app-monitor</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<artifactId>xtools-app-monitor-boot</artifactId>
|
||||
|
||||
<!-- 依赖 -->
|
||||
<dependencies>
|
||||
<!-- xtools-cloud-alibaba-nacos -->
|
||||
<dependency>
|
||||
<groupId>org.xujun</groupId>
|
||||
<artifactId>xtools-cloud-alibaba-nacos</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- SpringBoot begin -->
|
||||
<!-- SpringBootAdmin -->
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-server</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringBoot-Security(权限模块) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringBoot-Web -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.hibernate.validator</groupId>
|
||||
<artifactId>hibernate-validator</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- SpringBoot end -->
|
||||
</dependencies>
|
||||
|
||||
<!-- 构建 -->
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.cyclonedx</groupId>
|
||||
<artifactId>cyclonedx-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,48 @@
|
||||
package xtools.app;
|
||||
|
||||
import de.codecentric.boot.admin.server.config.EnableAdminServer;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.util.StopWatch;
|
||||
import xtools.boot.core.utils.AppUtils;
|
||||
|
||||
/**
|
||||
* <p>Title : MonitorApplication</p>
|
||||
* <p>Description : MonitorApplication</p>
|
||||
* <p>DevelopTools : Idea_x64_v2026.1</p>
|
||||
* <p>DevelopSystem : macOS Sequoia 15.7.5</p>
|
||||
* <p>Company : org.xujun</p>
|
||||
*
|
||||
* @author : XuJun
|
||||
* @version : 1.0.0
|
||||
* @date : 2026/01/17 12:30
|
||||
*/
|
||||
@Slf4j
|
||||
@EnableAdminServer
|
||||
@SpringBootApplication
|
||||
public class MonitorApplication {
|
||||
|
||||
/**
|
||||
* Main
|
||||
*
|
||||
* @param args 参数
|
||||
*/
|
||||
static void main(String[] args) {
|
||||
StopWatch sw = new StopWatch();
|
||||
sw.start();
|
||||
runApp(args);
|
||||
sw.stop();
|
||||
log.info(AppUtils.info(sw.getTotalTimeMillis()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 运行App
|
||||
*
|
||||
* @param args 参数
|
||||
*/
|
||||
public static void runApp(String[] args) {
|
||||
SpringApplication.run(MonitorApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package xtools.app.monitor.boot.config;
|
||||
|
||||
import de.codecentric.boot.admin.server.config.AdminServerProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||
import org.springframework.security.config.annotation.web.configurers.HeadersConfigurer;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
|
||||
|
||||
/**
|
||||
* <p>Title : SecurityConfig</p>
|
||||
* <p>Description : SecurityConfig</p>
|
||||
* <p>DevelopTools : Idea_x64_v2026.1</p>
|
||||
* <p>DevelopSystem : macOS Sequoia 15.7.5</p>
|
||||
* <p>Company : org.xujun</p>
|
||||
*
|
||||
* @author : XuJun
|
||||
* @version : 1.0.0
|
||||
* @date : 2026/01/17 12:30
|
||||
*/
|
||||
@Configuration
|
||||
public class SecurityConfig {
|
||||
|
||||
/**
|
||||
* Admin配置信息
|
||||
**/
|
||||
private final String adminContextPath;
|
||||
|
||||
/**
|
||||
* 构造方法
|
||||
*
|
||||
* @param adminServerProperties AdminServer配置信息
|
||||
*/
|
||||
public SecurityConfig(AdminServerProperties adminServerProperties) {
|
||||
this.adminContextPath = adminServerProperties.getContextPath();
|
||||
}
|
||||
|
||||
/**
|
||||
* 自定义Security过滤链
|
||||
*
|
||||
* @param httpSecurity HttpSecurity
|
||||
* @return Security过滤链
|
||||
*/
|
||||
@Bean
|
||||
SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) {
|
||||
// 登录成功处理类
|
||||
SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
|
||||
successHandler.setTargetUrlParameter("redirectTo");
|
||||
successHandler.setDefaultTargetUrl(adminContextPath + "/");
|
||||
|
||||
// 无需授权的资源
|
||||
String[] urls = {
|
||||
// 静态文件
|
||||
adminContextPath + "/assets/**",
|
||||
// 登录页面
|
||||
adminContextPath + "/login"
|
||||
};
|
||||
|
||||
httpSecurity
|
||||
.headers(header -> header.frameOptions(HeadersConfigurer.FrameOptionsConfig::disable))
|
||||
// 授权机制
|
||||
.authorizeHttpRequests(auth -> auth.requestMatchers(urls).permitAll().anyRequest().authenticated())
|
||||
// 登录页面配置,用于替换security默认页面
|
||||
.formLogin(req -> req.loginPage(adminContextPath + "/login").successHandler(successHandler))
|
||||
// 登出页面配置,用于替换security默认页面
|
||||
.logout(req -> req.logoutUrl(adminContextPath + "/logout"))
|
||||
// 启用httpBasic认证模式
|
||||
.httpBasic(httpBasic -> {
|
||||
})
|
||||
// 禁用csrf
|
||||
.csrf(AbstractHttpConfigurer::disable);
|
||||
return httpSecurity.build();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
spring:
|
||||
boot:
|
||||
admin:
|
||||
# UI配置
|
||||
ui:
|
||||
# 页面标题
|
||||
title: ${MONITOR_UI_TITLE:xToolsMonitor}
|
||||
# 导航栏中显示的品牌
|
||||
brand: ${MONITOR_UI_BRAND:xToolsMonitor}
|
||||
@@ -0,0 +1,15 @@
|
||||
# App信息
|
||||
info:
|
||||
app:
|
||||
# 作者
|
||||
author: '@project.organization.name@'
|
||||
# 项目名
|
||||
name: '@project.artifactId@'
|
||||
# 版本号
|
||||
version: '@project.version@'
|
||||
# 项目编码
|
||||
encoding: '@project.build.sourceEncoding@'
|
||||
# Url
|
||||
url: '@project.organization.url@'
|
||||
# Java版本
|
||||
java: '@java.version@'
|
||||
@@ -0,0 +1,35 @@
|
||||
# Spring 信息
|
||||
spring:
|
||||
cloud:
|
||||
# Nacos 配置信息
|
||||
nacos:
|
||||
# Nacos 发现配置信息
|
||||
discovery:
|
||||
# Nacos 发现服务器地址
|
||||
server-addr: ${NACOS_SERVICE_HOST:127.0.0.1}:${NACOS_SERVICE_PORT:8848}
|
||||
# Nacos 发现服务器用户名
|
||||
username: ${NACOS_SERVICE_USERNAME:nacos}
|
||||
# Nacos 发现服务器密码
|
||||
password: ${NACOS_SERVICE_PASSWORD:nacos}
|
||||
# Nacos 发现服务器命名空间(默认为Public),可以省略不写
|
||||
namespace: ${NACOS_DISCOVERY_NAMESPACE:xtools-cloud}
|
||||
# 仅ipv4模式
|
||||
ip-type: IPv4
|
||||
# Nacos 配置中心信息
|
||||
config:
|
||||
# Nacos 配置服务器地址
|
||||
server-addr: ${NACOS_SERVICE_HOST:127.0.0.1}:${NACOS_SERVICE_PORT:8848}
|
||||
# Nacos 配置服务器用户名
|
||||
username: ${NACOS_SERVICE_USERNAME:nacos}
|
||||
# Nacos 配置服务器密码
|
||||
password: ${NACOS_SERVICE_PASSWORD:nacos}
|
||||
# Nacos 配置服务器命名空间(默认为Public),可以省略不写
|
||||
namespace: ${NACOS_CONFIG_NAMESPACE:xtools-cloud}
|
||||
# 配置文件
|
||||
config:
|
||||
import:
|
||||
# Boot配置文件
|
||||
- nacos:application-boot-log.yaml?refreshEnabled=true&group=BOOT
|
||||
- nacos:application-boot-monitor.yaml?refreshEnabled=true&group=BOOT
|
||||
# App配置文件
|
||||
- nacos:application-app-monitor.yaml?refreshEnabled=true&group=APP
|
||||
@@ -0,0 +1,16 @@
|
||||
# Spring 配置
|
||||
spring:
|
||||
# 应用配置
|
||||
application:
|
||||
# 应用名称
|
||||
name: xtools-app-monitor
|
||||
# 环境配置
|
||||
profiles:
|
||||
active:
|
||||
- info
|
||||
- nacos
|
||||
|
||||
# 服务器配置
|
||||
server:
|
||||
# 端口
|
||||
port: ${MONITOR_SERVICE_PORT:18100}
|
||||
37
xtools-app-monitor/xtools-app-monitor-client/pom.xml
Normal file
37
xtools-app-monitor/xtools-app-monitor-client/pom.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>org.xujun</groupId>
|
||||
<artifactId>xtools-app-monitor</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<artifactId>xtools-app-monitor-client</artifactId>
|
||||
|
||||
<!-- 依赖 -->
|
||||
<dependencies>
|
||||
<!-- xtools-boot begin -->
|
||||
<!-- xtools-boot-core -->
|
||||
<dependency>
|
||||
<groupId>org.xujun</groupId>
|
||||
<artifactId>xtools-boot-core</artifactId>
|
||||
</dependency>
|
||||
<!-- xtools-boot end -->
|
||||
|
||||
<!-- SpringBoot begin -->
|
||||
<!-- SpringBootAdmin客户端 -->
|
||||
<dependency>
|
||||
<groupId>de.codecentric</groupId>
|
||||
<artifactId>spring-boot-admin-starter-client</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringBoot-Security(权限模块) -->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-security</artifactId>
|
||||
</dependency>
|
||||
<!-- SpringBoot end -->
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,33 @@
|
||||
package xtools.app.monitor.client.config;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
import xtools.boot.core.interfaces.FilterWhitelist;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>Title : BootAdminFilterWhitelist</p>
|
||||
* <p>Description : BootAdminFilterWhitelist</p>
|
||||
* <p>DevelopTools : Idea_x64_v2026.1</p>
|
||||
* <p>DevelopSystem : macOS Sequoia 15.7.5</p>
|
||||
* <p>Company : org.xujun</p>
|
||||
*
|
||||
* @author : XuJun
|
||||
* @version : 1.0.0
|
||||
* @date : 2026/3/8 12:28
|
||||
*/
|
||||
@Component
|
||||
public class BootAdminFilterWhitelist implements FilterWhitelist {
|
||||
|
||||
/**
|
||||
* 添加过滤器白名单
|
||||
*
|
||||
* @return 过滤器白名单
|
||||
*/
|
||||
@Override
|
||||
public Set<String> add() {
|
||||
return Set.of(
|
||||
"/actuator/**"
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package xtools.app.monitor.client.config;
|
||||
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
|
||||
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
|
||||
import org.springframework.security.web.SecurityFilterChain;
|
||||
|
||||
/**
|
||||
* <p>Title : SecurityConfig</p>
|
||||
* <p>Description : SecurityConfig</p>
|
||||
* <p>DevelopTools : Idea_x64_v2026.1</p>
|
||||
* <p>DevelopSystem : macOS Sequoia 15.7.5</p>
|
||||
* <p>Company : org.xujun</p>
|
||||
*
|
||||
* @author : XuJun
|
||||
* @version : 1.0.0
|
||||
* @date : 2026/01/17 12:30
|
||||
*/
|
||||
@Configuration
|
||||
//@AutoConfiguration(before = ManagementWebSecurityAutoConfiguration.class)
|
||||
public class BootAdminSecurityConfig {
|
||||
|
||||
/**
|
||||
* 自定义Security过滤链
|
||||
*
|
||||
* @param httpSecurity HttpSecurity
|
||||
* @return Security过滤链
|
||||
*/
|
||||
@Bean
|
||||
SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) {
|
||||
httpSecurity
|
||||
// [/actuator/**]下的所有请求需要权限,其他请求全部允许
|
||||
.authorizeHttpRequests(
|
||||
auth -> auth.requestMatchers("/actuator/**").authenticated().anyRequest().permitAll())
|
||||
// 启用httpBasic认证模式
|
||||
.httpBasic(_ -> {
|
||||
})
|
||||
// 禁用csrf
|
||||
.csrf(AbstractHttpConfigurer::disable);
|
||||
return httpSecurity.build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
# App信息
|
||||
info:
|
||||
app:
|
||||
# 作者
|
||||
author: '@project.organization.name@'
|
||||
# 项目名
|
||||
name: '@project.artifactId@'
|
||||
# 版本号
|
||||
version: '@project.version@'
|
||||
# 项目编码
|
||||
encoding: '@project.build.sourceEncoding@'
|
||||
# Url
|
||||
url: '@project.organization.url@'
|
||||
# Java版本
|
||||
java: '@java.version@'
|
||||
Reference in New Issue
Block a user