diff --git a/pom.xml b/pom.xml
index d71181b1..34be51b0 100644
--- a/pom.xml
+++ b/pom.xml
@@ -198,6 +198,7 @@
ruoyi-generator
ruoyi-common
ruoyi-demo
+ ruoyi-extend
pom
diff --git a/ruoyi-admin/src/main/resources/application.yml b/ruoyi-admin/src/main/resources/application.yml
index 4d48a976..3352d1d7 100644
--- a/ruoyi-admin/src/main/resources/application.yml
+++ b/ruoyi-admin/src/main/resources/application.yml
@@ -64,6 +64,8 @@ logging:
# Spring配置
spring:
+ application:
+ name: ${ruoyi.name}
# 资源信息
messages:
# 国际化资源文件路径
@@ -317,18 +319,16 @@ spring:
--- # 监控配置
spring:
- application:
- name: ruoyi-vue-plus
boot:
admin:
# Spring Boot Admin Client 客户端的相关配置
client:
# 设置 Spring Boot Admin Server 地址
- url: http://localhost:${server.port}${spring.boot.admin.context-path}
+ url: http://localhost:9090/admin
instance:
prefer-ip: true # 注册实例时,优先使用 IP
- # Spring Boot Admin Server 服务端的相关配置
- context-path: /admin # 配置 Spring
+ username: ruoyi
+ password: 123456
# Actuator 监控端点的配置项
management:
@@ -338,6 +338,7 @@ management:
base-path: /actuator
exposure:
# 需要开放的端点。默认值只打开 health 和 info 两个端点。通过设置 * ,可以开放所有端点。
+ # 生产环境不建议放开所有 根据项目需求放开即可
include: '*'
endpoint:
logfile:
diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml
index aeafac81..47b9a55f 100644
--- a/ruoyi-common/pom.xml
+++ b/ruoyi-common/pom.xml
@@ -116,10 +116,6 @@
feign-okhttp
-
- de.codecentric
- spring-boot-admin-starter-server
-
de.codecentric
spring-boot-admin-starter-client
diff --git a/ruoyi-extend/pom.xml b/ruoyi-extend/pom.xml
new file mode 100644
index 00000000..99a2594e
--- /dev/null
+++ b/ruoyi-extend/pom.xml
@@ -0,0 +1,18 @@
+
+
+
+ ruoyi-vue-plus
+ com.ruoyi
+ 2.4.0
+
+ 4.0.0
+ ruoyi-extend
+ pom
+
+
+ ruoyi-monitor-admin
+
+
+
diff --git a/ruoyi-extend/ruoyi-monitor-admin/pom.xml b/ruoyi-extend/ruoyi-monitor-admin/pom.xml
new file mode 100644
index 00000000..c6ef4850
--- /dev/null
+++ b/ruoyi-extend/ruoyi-monitor-admin/pom.xml
@@ -0,0 +1,33 @@
+
+
+
+ ruoyi-extend
+ com.ruoyi
+ 2.4.0
+
+ 4.0.0
+ jar
+ ruoyi-monitor-admin
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-web
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-security
+
+
+
+ de.codecentric
+ spring-boot-admin-starter-server
+
+
+
+
diff --git a/ruoyi-extend/ruoyi-monitor-admin/src/main/java/com/ruoyi/monitor/admin/MonitorAdminApplication.java b/ruoyi-extend/ruoyi-monitor-admin/src/main/java/com/ruoyi/monitor/admin/MonitorAdminApplication.java
new file mode 100644
index 00000000..1d1cbca5
--- /dev/null
+++ b/ruoyi-extend/ruoyi-monitor-admin/src/main/java/com/ruoyi/monitor/admin/MonitorAdminApplication.java
@@ -0,0 +1,19 @@
+package com.ruoyi.monitor.admin;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+/**
+ * Admin 监控启动程序
+ *
+ * @author Lion Li
+ */
+@SpringBootApplication
+public class MonitorAdminApplication {
+
+ public static void main(String[] args) {
+ SpringApplication.run(MonitorAdminApplication.class, args);
+ System.out.println("Admin 监控启动成功" );
+ }
+
+}
diff --git a/ruoyi-extend/ruoyi-monitor-admin/src/main/java/com/ruoyi/monitor/admin/config/AdminServerConfig.java b/ruoyi-extend/ruoyi-monitor-admin/src/main/java/com/ruoyi/monitor/admin/config/AdminServerConfig.java
new file mode 100644
index 00000000..e2a9c51d
--- /dev/null
+++ b/ruoyi-extend/ruoyi-monitor-admin/src/main/java/com/ruoyi/monitor/admin/config/AdminServerConfig.java
@@ -0,0 +1,31 @@
+package com.ruoyi.monitor.admin.config;
+
+import de.codecentric.boot.admin.server.config.EnableAdminServer;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
+import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
+import org.springframework.boot.task.TaskExecutorBuilder;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Lazy;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+
+import java.util.concurrent.Executor;
+
+/**
+ * springboot-admin server配置类
+ *
+ * @author Lion Li
+ */
+@Configuration
+@EnableAdminServer
+public class AdminServerConfig {
+
+ @Lazy
+ @Bean(name = TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME)
+ @ConditionalOnMissingBean(Executor.class)
+ public ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder builder) {
+ return builder.build();
+ }
+
+
+}
diff --git a/ruoyi-extend/ruoyi-monitor-admin/src/main/java/com/ruoyi/monitor/admin/config/SecurityConfig.java b/ruoyi-extend/ruoyi-monitor-admin/src/main/java/com/ruoyi/monitor/admin/config/SecurityConfig.java
new file mode 100644
index 00000000..98834a9b
--- /dev/null
+++ b/ruoyi-extend/ruoyi-monitor-admin/src/main/java/com/ruoyi/monitor/admin/config/SecurityConfig.java
@@ -0,0 +1,48 @@
+package com.ruoyi.monitor.admin.config;
+
+import de.codecentric.boot.admin.server.config.AdminServerProperties;
+import org.springframework.context.annotation.Configuration;
+import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
+import org.springframework.security.config.annotation.web.builders.HttpSecurity;
+import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
+import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
+import org.springframework.security.web.authentication.SavedRequestAwareAuthenticationSuccessHandler;
+
+/**
+ * spring security配置
+ *
+ * @author ruoyi
+ */
+@Configuration
+@EnableWebSecurity
+@EnableGlobalMethodSecurity(prePostEnabled = true, securedEnabled = true, proxyTargetClass = true)
+public class SecurityConfig extends WebSecurityConfigurerAdapter {
+
+ private final String adminContextPath;
+
+ public SecurityConfig(AdminServerProperties adminServerProperties) {
+ this.adminContextPath = adminServerProperties.getContextPath();
+ }
+
+ @Override
+ protected void configure(HttpSecurity httpSecurity) throws Exception {
+ SavedRequestAwareAuthenticationSuccessHandler successHandler = new SavedRequestAwareAuthenticationSuccessHandler();
+ successHandler.setTargetUrlParameter("redirectTo");
+ successHandler.setDefaultTargetUrl(adminContextPath + "/");
+
+ httpSecurity.authorizeRequests()
+ //授予对所有静态资产和登录页面的公共访问权限。
+ .antMatchers(adminContextPath + "/assets/**").permitAll()
+ .antMatchers(adminContextPath + "/login").permitAll()
+ //必须对每个其他请求进行身份验证
+ .anyRequest().authenticated().and()
+ //配置登录和注销
+ .formLogin().loginPage(adminContextPath + "/login")
+ .successHandler(successHandler).and()
+ .logout().logoutUrl(adminContextPath + "/logout").and()
+ //启用HTTP-Basic支持。这是Spring Boot Admin Client注册所必需的
+ .httpBasic().and().csrf().disable()
+ .headers().frameOptions().disable();
+ }
+
+}
diff --git a/ruoyi-extend/ruoyi-monitor-admin/src/main/resources/application.yml b/ruoyi-extend/ruoyi-monitor-admin/src/main/resources/application.yml
new file mode 100644
index 00000000..631f3e77
--- /dev/null
+++ b/ruoyi-extend/ruoyi-monitor-admin/src/main/resources/application.yml
@@ -0,0 +1,11 @@
+server:
+ port: 9090
+
+spring:
+ security:
+ user:
+ name: ruoyi
+ password: 123456
+ boot:
+ admin:
+ context-path: /admin
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AdminServerConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AdminServerConfig.java
deleted file mode 100644
index 59fed507..00000000
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/AdminServerConfig.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.ruoyi.framework.config;
-
-import de.codecentric.boot.admin.server.config.EnableAdminServer;
-import org.springframework.beans.factory.ObjectProvider;
-import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
-import org.springframework.boot.autoconfigure.task.TaskExecutionAutoConfiguration;
-import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties;
-import org.springframework.boot.task.TaskExecutorBuilder;
-import org.springframework.context.annotation.Bean;
-import org.springframework.context.annotation.Configuration;
-import org.springframework.context.annotation.Lazy;
-import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
-import org.thymeleaf.dialect.IDialect;
-import org.thymeleaf.spring5.ISpringTemplateEngine;
-import org.thymeleaf.spring5.SpringTemplateEngine;
-import org.thymeleaf.templateresolver.ITemplateResolver;
-
-import java.util.Comparator;
-import java.util.LinkedHashSet;
-import java.util.Set;
-import java.util.concurrent.Executor;
-import java.util.stream.Collectors;
-
-/**
- * springboot-admin server配置类
- *
- * @author Lion Li
- */
-@Configuration
-@EnableAdminServer
-public class AdminServerConfig {
-
- @Lazy
- @Bean(name = TaskExecutionAutoConfiguration.APPLICATION_TASK_EXECUTOR_BEAN_NAME)
- @ConditionalOnMissingBean(Executor.class)
- public ThreadPoolTaskExecutor applicationTaskExecutor(TaskExecutorBuilder builder) {
- return builder.build();
- }
-
- /**
- * 解决 admin 与 项目 页面的交叉引用 将 admin 的路由放到最后
- * @param properties
- * @param templateResolvers
- * @param dialects
- * @return
- */
- @Bean
- @ConditionalOnMissingBean(ISpringTemplateEngine.class)
- SpringTemplateEngine templateEngine(ThymeleafProperties properties,
- ObjectProvider templateResolvers, ObjectProvider dialects) {
- SpringTemplateEngine engine = new SpringTemplateEngine();
- engine.setEnableSpringELCompiler(properties.isEnableSpringElCompiler());
- engine.setRenderHiddenMarkersBeforeCheckboxes(properties.isRenderHiddenMarkersBeforeCheckboxes());
- templateResolvers.orderedStream().forEach(engine::addTemplateResolver);
- dialects.orderedStream().forEach(engine::addDialect);
- Set templateResolvers1 = engine.getTemplateResolvers();
- templateResolvers1 = templateResolvers1.stream()
- .sorted(Comparator.comparing(ITemplateResolver::getOrder))
- .collect(Collectors.toCollection(LinkedHashSet::new));
- engine.setTemplateResolvers(templateResolvers1);
- return engine;
- }
-}
diff --git a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
index 79ade787..920aa888 100644
--- a/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
+++ b/ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -3,7 +3,6 @@ package com.ruoyi.framework.config;
import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl;
import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl;
-import de.codecentric.boot.admin.server.config.AdminServerProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.http.HttpMethod;
@@ -57,9 +56,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
@Autowired
private CorsFilter corsFilter;
- @Autowired
- private AdminServerProperties adminServerProperties;
-
/**
* 解决 无法直接注入 AuthenticationManager
*
@@ -117,9 +113,6 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
.antMatchers("/webjars/**").anonymous()
.antMatchers("/*/api-docs").anonymous()
.antMatchers("/druid/**").anonymous()
- // Spring Boot Admin Server 的安全配置
- .antMatchers(adminServerProperties.getContextPath()).anonymous()
- .antMatchers(adminServerProperties.getContextPath() + "/**").anonymous()
// Spring Boot Actuator 的安全配置
.antMatchers("/actuator").anonymous()
.antMatchers("/actuator/**").anonymous()
diff --git a/ruoyi-ui/src/views/monitor/admin/index.vue b/ruoyi-ui/src/views/monitor/admin/index.vue
index f1d48b0a..012d92c5 100644
--- a/ruoyi-ui/src/views/monitor/admin/index.vue
+++ b/ruoyi-ui/src/views/monitor/admin/index.vue
@@ -8,7 +8,7 @@ export default {
name: "Admin",
data() {
return {
- src: process.env.VUE_APP_BASE_API + "/admin",
+ src: "http://localhost:9090/admin/login",
height: document.documentElement.clientHeight - 94.5 + "px;",
loading: true
};