add 集成 spring-boot-admin 全方位监控
| | |
| | | * swagger ä¿®æ¹ä¸º knife4j |
| | | * éæ Hutool 5.X å¹¶éåRuoYié¨ååè½ |
| | | * éæ Feign æ¥å£å管ç Http 请æ±(å¦ä¸æ¹è¯·æ± æ¯ä»,çä¿¡,æ¨éç) |
| | | * éæ spring-boot-admin å
¨æ¹ä½çæ§ |
| | | * å级MybatisPlus 3.4.2 |
| | | * å¢å demo模å示ä¾(ç»ä¸ä¼å¢å 模åçå°ä¼ä¼´ååè) |
| | | * 忥å级 3.4.0 |
| | |
| | | <hutool.version>5.5.8</hutool.version> |
| | | <feign.version>2.2.6.RELEASE</feign.version> |
| | | <feign-okhttp.version>11.0</feign-okhttp.version> |
| | | <spring-boot-admin.version>2.3.1</spring-boot-admin.version> |
| | | </properties> |
| | | |
| | | <!-- ä¾èµå£°æ --> |
| | |
| | | <version>${feign-okhttp.version}</version> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>de.codecentric</groupId> |
| | | <artifactId>spring-boot-admin-starter-server</artifactId> |
| | | <version>${spring-boot-admin.version}</version> |
| | | </dependency> |
| | | <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-starter-actuator</artifactId> |
| | | </dependency> |
| | | |
| | | <!-- 宿¶ä»»å¡--> |
| | | <dependency> |
| | | <groupId>com.ruoyi</groupId> |
| | |
| | | allow: |
| | | url-pattern: /druid/* |
| | | # æ§å¶å°ç®¡çç¨æ·ååå¯ç |
| | | login-username: |
| | | login-password: |
| | | login-username: ruoyi |
| | | login-password: 123456 |
| | | filter: |
| | | stat: |
| | | enabled: true |
| | |
| | | level: |
| | | com.ruoyi: @logging.level@ |
| | | org.springframework: warn |
| | | config: classpath:logback.xml |
| | | |
| | | # Springé
ç½® |
| | | spring: |
| | |
| | | restart: |
| | | # çé¨ç½²å¼å
³ |
| | | enabled: true |
| | | 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} |
| | | instance: |
| | | prefer-ip: true # 注åå®ä¾æ¶ï¼ä¼å
ä½¿ç¨ IP |
| | | # username: ruoyi |
| | | # password: 123456 |
| | | # Spring Boot Admin Server æå¡ç«¯çç¸å
³é
ç½® |
| | | context-path: /admin # é
ç½® Spring |
| | | |
| | | # Actuator çæ§ç«¯ç¹çé
置项 |
| | | management: |
| | | endpoints: |
| | | web: |
| | | # Actuator æä¾ç API æ¥å£çæ ¹ç®å½ãé»è®¤ä¸º /actuator |
| | | base-path: /actuator |
| | | exposure: |
| | | # éè¦å¼æ¾ç端ç¹ãé»è®¤å¼åªæå¼ health å info 两个端ç¹ãéè¿è®¾ç½® * ï¼å¯ä»¥å¼æ¾ææç«¯ç¹ã |
| | | include: '*' |
| | | endpoint: |
| | | logfile: |
| | | external-file: ./logs/sys-console.log |
| | | |
| | | # tokené
ç½® |
| | | token: |
| | |
| | | <charset>utf-8</charset> |
| | | </encoder> |
| | | </appender> |
| | | |
| | | <!-- æ§å¶å°è¾åº --> |
| | | <appender name="file_console" class="ch.qos.logback.core.FileAppender"> |
| | | <file>${log.path}/sys-console.log</file> |
| | | <encoder> |
| | | <pattern>${log.pattern}</pattern> |
| | | <charset>utf-8</charset> |
| | | </encoder> |
| | | <filter class="ch.qos.logback.classic.filter.ThresholdFilter"> |
| | | <!-- è¿æ»¤ççº§å« --> |
| | | <level>INFO</level> |
| | | </filter> |
| | | </appender> |
| | | |
| | | <!-- ç³»ç»æ¥å¿è¾åº --> |
| | | <appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender"> |
| | |
| | | <root level="info"> |
| | | <appender-ref ref="file_info" /> |
| | | <appender-ref ref="file_error" /> |
| | | <appender-ref ref="file_console" /> |
| | | </root> |
| | | |
| | | <!--ç³»ç»ç¨æ·æä½æ¥å¿--> |
| | |
| | | <artifactId>feign-okhttp</artifactId> |
| | | </dependency> |
| | | |
| | | <dependency> |
| | | <groupId>de.codecentric</groupId> |
| | | <artifactId>spring-boot-admin-starter-server</artifactId> |
| | | </dependency> |
| | | <dependency> |
| | | <groupId>de.codecentric</groupId> |
| | | <artifactId>spring-boot-admin-starter-client</artifactId> |
| | | </dependency> |
| | | |
| | | </dependencies> |
| | | |
| | | </project> |
¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.framework.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; |
| | | |
| | | @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(); |
| | | } |
| | | } |
| | |
| | | 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; |
| | |
| | | import org.springframework.security.web.authentication.UsernamePasswordAuthenticationFilter; |
| | | import org.springframework.security.web.authentication.logout.LogoutFilter; |
| | | import org.springframework.web.filter.CorsFilter; |
| | | import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter; |
| | | import com.ruoyi.framework.security.handle.AuthenticationEntryPointImpl; |
| | | import com.ruoyi.framework.security.handle.LogoutSuccessHandlerImpl; |
| | | |
| | | /** |
| | | * spring securityé
ç½® |
| | |
| | | */ |
| | | @Autowired |
| | | private CorsFilter corsFilter; |
| | | |
| | | @Autowired |
| | | private AdminServerProperties adminServerProperties; |
| | | |
| | | /** |
| | | * è§£å³ æ æ³ç´æ¥æ³¨å
¥ AuthenticationManager |
| | |
| | | .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() |
| | | // é¤ä¸é¢å¤çææè¯·æ±å
¨é¨éè¦é´æè®¤è¯ |
| | | .anyRequest().authenticated() |
| | | .and() |
¶Ô±ÈÐÂÎļþ |
| | |
| | | <template> |
| | | <div v-loading="loading" :style="'height:'+ height"> |
| | | <iframe :src="src" frameborder="no" style="width: 100%;height: 100%" scrolling="auto" /> |
| | | </div> |
| | | </template> |
| | | <script> |
| | | export default { |
| | | name: "Admin", |
| | | data() { |
| | | return { |
| | | src: process.env.VUE_APP_BASE_API + "/admin", |
| | | height: document.documentElement.clientHeight - 94.5 + "px;", |
| | | loading: true |
| | | }; |
| | | }, |
| | | mounted: function() { |
| | | setTimeout(() => { |
| | | this.loading = false; |
| | | }, 230); |
| | | const that = this; |
| | | window.onresize = function temp() { |
| | | that.height = document.documentElement.clientHeight - 94.5 + "px;"; |
| | | }; |
| | | } |
| | | }; |
| | | </script> |
| | |
| | | insert into sys_menu values('114', '表åæå»º', '3', '1', 'build', 'tool/build/index', 1, 0, 'C', '0', '0', 'tool:build:list', 'build', 'admin', sysdate(), '', null, '表åæå»ºèå'); |
| | | insert into sys_menu values('115', '代ç çæ', '3', '2', 'gen', 'tool/gen/index', 1, 0, 'C', '0', '0', 'tool:gen:list', 'code', 'admin', sysdate(), '', null, '代ç çæèå'); |
| | | insert into sys_menu values('116', 'ç³»ç»æ¥å£', '3', '3', 'swagger', 'tool/swagger/index', 1, 0, 'C', '0', '0', 'tool:swagger:list', 'swagger', 'admin', sysdate(), '', null, 'ç³»ç»æ¥å£èå'); |
| | | -- springboot-adminçæ§ |
| | | insert into sys_menu values('117', 'Adminçæ§', '2', '5', 'Admin', 'monitor/admin/index', 1, 0, 'C', '0', '0', 'monitor:admin:list', 'dashboard', 'admin', sysdate(), '', null, 'Adminçæ§èå'); |
| | | |
| | | -- ä¸çº§èå |
| | | insert into sys_menu values('500', 'æä½æ¥å¿', '108', '1', 'operlog', 'monitor/operlog/index', 1, 0, 'C', '0', '0', 'monitor:operlog:list', 'form', 'admin', sysdate(), '', null, 'æä½æ¥å¿èå'); |
| | | insert into sys_menu values('501', 'ç»å½æ¥å¿', '108', '2', 'logininfor', 'monitor/logininfor/index', 1, 0, 'C', '0', '0', 'monitor:logininfor:list', 'logininfor', 'admin', sysdate(), '', null, 'ç»å½æ¥å¿èå'); |