springboot
Spring Boot实战之入门
SpringBoot-WebSocket广播消息+单点消息(指定用户发送消息)
Spring Boot实战之Filter实现使用JWT进行接口认证
springboot +shiro+前后端权限处理
springboot(十四):springboot整合shiro-登录认证和权限管理
基于SpringBoot + Mybatis + webpack+VueJs + ElementUI编写的管理系统(一)
spring boot shiro redis整合基于角色和权限的安全管理-Java编程
SpringBoot整合mybatis、shiro、redis实现基于数据库的细粒度动态权限管理系统实例
[springBoot系列]--springBoot注解大全
Spring Boot有四大神器,分别是auto-configuration、starters、cli、actuator,本文主要讲actuator。actuator是spring boot提供的对应用系统的自省和监控的集成功能,可以对应用系统进行配置查看、相关功能统计等。
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency>
主要暴露的功能:

SpringBoot的starter主要用来简化依赖用的。主要分两部分,一部分是列出一些starter的依赖,另一部分是教你自己写一个starter。
部分starters的依赖:Starter(Group ID: org.springframework.boot)
spring-boot-starter-log4j2
spring-boot-starter-logging
spring-boot-starter-mail
spring-boot-starter-mobile
spring-boot-starter-mustache
spring-boot-starter-redis
spring-boot-starter-remote-shell
spring-boot-starter-security
spring-boot-starter-social-facebook
spring-boot-starter-social-linkedin
spring-boot-starter-social-twitter
spring-boot-starter-test
spring-boot-starter-thymeleaf
spring-boot-starter-tomcat
spring-boot-starter-undertow
spring-boot-starter-validation
spring-boot-starter-velocity
spring-boot-starter-web
spring-boot-starter-websocket
spring-boot-starter-ws
如何自己写starter
主要步骤
-
1、选择已有的starters,在此基础上进行扩展.
-
2、创建自动配置文件并设定META-INF/spring.factories里的内容.
-
3、发布你的starter
添加依赖管理
<dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-dependencies</artifactId> <version>${spring.boot.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>
添加starter自己的依赖
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
新建configuration
@Configuration @ComponentScan( basePackages = {"com.patterncat.actuator"} ) public class WebAutoConfiguration { /** * addViewController方法不支持placeholder的解析 * 故在这里用变量解析出来 */ @Value("${actuator.web.base:}") String actuatorBase; // @Bean // public ActuatorNavController actuatorNavController(){ // return new ActuatorNavController(); // } @Bean public WebMvcConfigurerAdapter configStaticMapping() { return new WebMvcConfigurerAdapter() { @Override public void addViewControllers(ViewControllerRegistry registry) { //配置跳转 registry.addViewController(actuatorBase+"/nav").setViewName( "forward:/static/nav.html"); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/static/**"). addResourceLocations("classpath:/static/"); } }; } }
修改/META-INF/spring.factories
# AutoConfigurations
org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.patterncat.actuator.configuration.WebAutoConfiguration
发布:mvn clean install
引用
<dependency> <groupId>com.patterncat</groupId> <artifactId>spring-boot-starter-actuator-web</artifactId> <version>1.0-SNAPSHOT</version> </dependency>
启动访问:mvn spring-boot:run
访问:http://localhost:8080/nav
浙公网安备 33010602011771号