Spring Boot做为单体服务的容器,相较SSM简化了大量的配置。官方网站java
咱们能够选择从官方在线下载ZIP包Spring Initializr ,也能够用Idea自带的Spring Initializr构建。git
以整合actuator为例,展现Spring Boot开发的三个步骤。访问http://localhost:8080/actuator查看是否整合成功。web
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
复制代码
不须要写注解
复制代码
# actuator
management:
endpoints:
web:
exposure:
include: '*'
endpoint:
health:
show-details: always
# info
info:
app-name: virgo-service-lock
author: zhaozha
复制代码
经过java -jar springboot-demo-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev指定环境进行测试 spring
# 经过连字符的形式
# 公共部分
server:
port: 8080
## actuator
management:
endpoints:
web:
exposure:
# 生产不建议所有放开
include: '*'
# /actuator -> /monitor
base-path: '/monitor'
endpoint:
health:
show-details: always
#优雅停机
shutdown:
enabled: true
# info
info:
app-name: springboot-demo
author: zhao
---
#开发部分
spring:
profiles: dev
---
#生产部分
spring:
profiles: prod
server:
tomcat:
max-threads: 300
max-connections: 1000
复制代码
# 经过配置文件命名的方式
application.properties
dev-application.properties
prod-application.properties
复制代码
经过actuator的shutdown便可。tomcat
#开机
java -jar springboot-demo-0.0.1-SNAPSHOT.jar --spring.profiles.active=dev
#停机(须要定义安全措施,直接暴露风险很大)
curl -X POST http://localhost:8080/monitor/shutdown
复制代码
文章如有谬误之处,但愿广大读者指正,互相交流,共同提升。springboot