commit 0d142880c903deb02d1dee9f2b6bb5d73fa8e3a3
Author: 少年梦与砖 <2847127106@qq.com>
Date: Wed Jul 24 14:54:42 2024 +0800
初始化
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..09bdfea
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,46 @@
+######################################################################
+# Build Tools
+
+.gradle
+/build/
+!gradle/wrapper/gradle-wrapper.jar
+
+target/
+!.mvn/wrapper/maven-wrapper.jar
+
+######################################################################
+# IDE
+
+### STS ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+
+### IntelliJ IDEA ###
+.idea
+*.iws
+*.iml
+*.ipr
+
+### JRebel ###
+rebel.xml
+### NetBeans ###
+nbproject/private/
+build/*
+nbbuild/
+dist/
+nbdist/
+.nb-gradle/
+
+######################################################################
+# Others
+*.log
+*.xml.versionsBackup
+*.swp
+
+!*/build/*.java
+!*/build/*.html
+!*/build/*.xml
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
new file mode 100644
index 0000000..88179d0
--- /dev/null
+++ b/pom.xml
@@ -0,0 +1,81 @@
+
+
+ com.muyu
+ cloud-visual
+ 3.6.3
+
+ 4.0.0
+
+ cloud-visual-monitor
+
+
+ cloud-visual-monitor监控中心
+
+
+
+
+
+
+ de.codecentric
+ spring-boot-admin-starter-server
+ ${spring-boot-admin.version}
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-discovery
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-nacos-config
+
+
+
+
+ com.alibaba.cloud
+ spring-cloud-starter-alibaba-sentinel
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+
+
+
+ ${project.artifactId}
+
+
+ org.springframework.boot
+ spring-boot-maven-plugin
+
+
+
+ repackage
+
+
+
+
+
+
+
+
+ yun-releases
+ yun-releases
+ http://47.116.173.119:8081/repository/maven-releases/
+
+
+
diff --git a/src/main/java/com/muyu/modules/monitor/CloudMonitorApplication.java b/src/main/java/com/muyu/modules/monitor/CloudMonitorApplication.java
new file mode 100644
index 0000000..20380db
--- /dev/null
+++ b/src/main/java/com/muyu/modules/monitor/CloudMonitorApplication.java
@@ -0,0 +1,19 @@
+package com.muyu.modules.monitor;
+
+import de.codecentric.boot.admin.server.config.EnableAdminServer;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * 监控中心
+ *
+ * @author muyu
+ */
+@EnableAdminServer
+@SpringBootApplication
+public class CloudMonitorApplication {
+ public static void main (String[] args) {
+ SpringApplication.run(CloudMonitorApplication.class, args);
+ System.out.println("CloudMonitor 模块启动成功!");
+ }
+}
diff --git a/src/main/java/com/muyu/modules/monitor/config/WebSecurityConfigurer.java b/src/main/java/com/muyu/modules/monitor/config/WebSecurityConfigurer.java
new file mode 100644
index 0000000..d1bc9f4
--- /dev/null
+++ b/src/main/java/com/muyu/modules/monitor/config/WebSecurityConfigurer.java
@@ -0,0 +1,37 @@
+package com.muyu.modules.monitor.config;
+
+import de.codecentric.boot.admin.server.config.AdminServerProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.web.SecurityFilterChain;
+import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
+
+/**
+ * 监控权限配置
+ *
+ * @author muyu
+ */
+@EnableWebSecurity
+public class WebSecurityConfigurer {
+ private final String adminContextPath;
+
+ public WebSecurityConfigurer (AdminServerProperties adminServerProperties) {
+ this.adminContextPath = adminServerProperties.getContextPath();
+ }
+
+ @Bean
+ public SecurityFilterChain filterChain (HttpSecurity httpSecurity) throws Exception {
+ SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
+ successHandler.setTargetUrlParameter("redirectTo");
+ successHandler.setDefaultTargetUrl(adminContextPath + "/");
+
+ return httpSecurity
+ .authorizeHttpRequests((authorize) -> authorize .anyRequest().authenticated())
+ .securityMatcher(adminContextPath + "/assets/**"
+ , adminContextPath + "/login"
+ , adminContextPath + "/actuator/**"
+ , adminContextPath + "/instances/**"
+ ).build();
+ }
+}
diff --git a/src/main/resources/banner.txt b/src/main/resources/banner.txt
new file mode 100644
index 0000000..0dd5eee
--- /dev/null
+++ b/src/main/resources/banner.txt
@@ -0,0 +1,2 @@
+Spring Boot Version: ${spring-boot.version}
+Spring Application Name: ${spring.application.name}
diff --git a/src/main/resources/bootstrap.yml b/src/main/resources/bootstrap.yml
new file mode 100644
index 0000000..7fa85b2
--- /dev/null
+++ b/src/main/resources/bootstrap.yml
@@ -0,0 +1,47 @@
+# Tomcat
+server:
+ port: 9100
+
+# nacos线上地址
+nacos:
+ addr: 47.116.173.119:8848
+ user-name: nacos
+ password: nacos
+ namespace: 9a848700-2a37-4ca1-bb66-3ef384e4c3b9
+
+# Spring
+spring:
+ application:
+ # 应用名称
+ name: cloud-monitor
+ profiles:
+ # 环境配置
+ active: dev
+ cloud:
+ nacos:
+ discovery:
+ # 服务注册地址
+ server-addr: ${nacos.addr}
+ # nacos用户名
+ username: ${nacos.user-name}
+ # nacos密码
+ password: ${nacos.password}
+ # 命名空间
+ namespace: ${nacos.namespace}
+ config:
+ # 服务注册地址
+ server-addr: ${nacos.addr}
+ # nacos用户名
+ username: ${nacos.user-name}
+ # nacos密码
+ password: ${nacos.password}
+ # 命名空间
+ namespace: ${nacos.namespace}
+ # 配置文件格式
+ file-extension: yml
+ # 共享配置
+ shared-configs:
+ # 系统共享配置
+ - application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
+ # 系统环境Config共享配置
+ - application-config-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
diff --git a/src/main/resources/logback/dev.xml b/src/main/resources/logback/dev.xml
new file mode 100644
index 0000000..44e127d
--- /dev/null
+++ b/src/main/resources/logback/dev.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+ ${log.pattern}
+
+
+
+
+
+ ${log.path}/info.log
+
+
+
+ ${log.path}/info.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ INFO
+
+ ACCEPT
+
+ DENY
+
+
+
+
+ ${log.path}/error.log
+
+
+
+ ${log.path}/error.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ ERROR
+
+ ACCEPT
+
+ DENY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/logback/prod.xml b/src/main/resources/logback/prod.xml
new file mode 100644
index 0000000..44e127d
--- /dev/null
+++ b/src/main/resources/logback/prod.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+ ${log.pattern}
+
+
+
+
+
+ ${log.path}/info.log
+
+
+
+ ${log.path}/info.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ INFO
+
+ ACCEPT
+
+ DENY
+
+
+
+
+ ${log.path}/error.log
+
+
+
+ ${log.path}/error.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ ERROR
+
+ ACCEPT
+
+ DENY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/main/resources/logback/test.xml b/src/main/resources/logback/test.xml
new file mode 100644
index 0000000..44e127d
--- /dev/null
+++ b/src/main/resources/logback/test.xml
@@ -0,0 +1,74 @@
+
+
+
+
+
+
+
+
+
+
+ ${log.pattern}
+
+
+
+
+
+ ${log.path}/info.log
+
+
+
+ ${log.path}/info.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ INFO
+
+ ACCEPT
+
+ DENY
+
+
+
+
+ ${log.path}/error.log
+
+
+
+ ${log.path}/error.%d{yyyy-MM-dd}.log
+
+ 60
+
+
+ ${log.pattern}
+
+
+
+ ERROR
+
+ ACCEPT
+
+ DENY
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+