# 运维部署

项目打包

  • spring-boot-plus项目使用maven assembly插件进行打包
  • 根据不同环境进行打包部署
  • 包含启动、重启命令,配置文件提取到外部config目录

# 项目打包

项目模块说明

  • 指定打包环境:dev:开发环境,test:测试环境,uat:用户验收,prod:生产环境
  • 指定打包模块:release:项目应用打包,release-admin:Spring Boot Admin打包

# 项目应用打包

mvn clean package -P dev,release

# Spring Boot Admin打包

mvn clean package -P dev,release-admin

# 启动方式

# 方式一:直接启动jar

# 启动Spring Boot Admin

cd spring-boot-plus/admin/target
nohup java -jar admin-2.0.jar &

# 启动项目

cd spring-boot-plus/bootstrap/target
nohup java -jar bootstrap-2.0.jar &

# 方式二:使用启动命令和外部配置 推荐

TIP

  • maven打包时,选择了release Profile时,会将项目打包到distribution模块的target目录下
  • spring-boot-plus-server-2.0.tar.gz上传到服务器,解压执行,类似与启动tomcat
  • 服务器上快速发布脚本:spring-boot-plus/docs/bin/deploy.sh,可自行修改配置

# 解压spring-boot-plus-server-2.0.tar.gz

cd spring-boot-plus/distribution/target
tar -zxvf spring-boot-plus-server-2.0.tar.gz

# 执行startup.sh启动服务

cd spring-boot-plus-server-2.0
sh bin/startup.sh

# 打包后的目录结构

# 主要目录

├── bin         启动/停止/重启服务命令目录
├── config      配置文件目录
├── lib         依赖jar包目录,jar包已分开
└── logs        项目运行日志目录

# 详细目录文件






 

 
 









 












 


 


 






















































 

























































 










├── LICENSE
├── README.md
├── bin
│   ├── restart.sh
│   ├── shutdown.sh
│   └── startup.sh
├── config
│   ├── application-dev.yml
│   ├── application.yml
│   ├── banner.txt
│   ├── logback.xml
│   └── mime-type.properties
├── lib
│   ├── HdrHistogram-2.1.11.jar
│   ├── HikariCP-3.4.2.jar
│   ├── LatencyUtils-2.0.3.jar
│   ├── annotations-2.0.1.jar
│   ├── aspectjweaver-1.9.5.jar
│   ├── bootstrap-2.0.jar
│   ├── byte-buddy-1.10.8.jar
│   ├── checker-qual-2.10.0.jar
│   ├── classmate-1.5.1.jar
│   ├── commons-beanutils-1.9.4.jar
│   ├── commons-codec-1.14.jar
│   ├── commons-collections-3.2.2.jar
│   ├── commons-collections4-4.4.jar
│   ├── commons-io-2.6.jar
│   ├── commons-lang3-3.9.jar
│   ├── commons-net-3.6.jar
│   ├── commons-pool2-2.8.0.jar
│   ├── commons-text-1.8.jar
│   ├── config-2.0.jar
│   ├── encoder-1.2.2.jar
│   ├── error_prone_annotations-2.3.4.jar
│   ├── example-2.0.jar
│   ├── failureaccess-1.0.1.jar
│   ├── fastjson-1.2.67.jar
│   ├── framework-2.0.jar
│   ├── guava-28.2-jre.jar
│   ├── hibernate-validator-6.0.18.Final.jar
│   ├── hutool-all-5.2.4.jar
│   ├── ini4j-0.5.4.jar
│   ├── j2objc-annotations-1.3.jar
│   ├── jackson-annotations-2.10.2.jar
│   ├── jackson-core-2.10.2.jar
│   ├── jackson-databind-2.10.2.jar
│   ├── jackson-datatype-jdk8-2.10.2.jar
│   ├── jackson-datatype-jsr310-2.10.2.jar
│   ├── jackson-module-parameter-names-2.10.2.jar
│   ├── jakarta.annotation-api-1.3.5.jar
│   ├── jakarta.validation-api-2.0.2.jar
│   ├── jansi-1.18.jar
│   ├── java-jwt-3.10.1.jar
│   ├── javassist-3.18.2-GA.jar
│   ├── jboss-logging-3.4.1.Final.jar
│   ├── jolokia-core-1.6.2.jar
│   ├── json-simple-1.1.1.jar
│   ├── jsqlparser-3.1.jar
│   ├── jsr305-3.0.2.jar
│   ├── jul-to-slf4j-1.7.30.jar
│   ├── knife4j-annotations-2.0.2.jar
│   ├── knife4j-core-2.0.2.jar
│   ├── knife4j-spring-2.0.2.jar
│   ├── knife4j-spring-boot-autoconfigure-2.0.2.jar
│   ├── knife4j-spring-boot-starter-2.0.2.jar
│   ├── knife4j-spring-ui-2.0.2.jar
│   ├── lettuce-core-5.2.2.RELEASE.jar
│   ├── listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar
│   ├── log4j-api-2.12.1.jar
│   ├── log4j-to-slf4j-2.12.1.jar
│   ├── logback-classic-1.2.3.jar
│   ├── logback-core-1.2.3.jar
│   ├── lombok-1.18.12.jar
│   ├── mapstruct-1.3.1.Final.jar
│   ├── micrometer-core-1.3.5.jar
│   ├── mybatis-3.5.3.jar
│   ├── mybatis-plus-3.3.1.jar
│   ├── mybatis-plus-annotation-3.3.1.jar
│   ├── mybatis-plus-boot-starter-3.3.1.jar
│   ├── mybatis-plus-core-3.3.1.jar
│   ├── mybatis-plus-extension-3.3.1.jar
│   ├── mybatis-spring-2.0.3.jar
│   ├── mysql-connector-java-5.1.47.jar
│   ├── netty-buffer-4.1.45.Final.jar
│   ├── netty-codec-4.1.45.Final.jar
│   ├── netty-common-4.1.45.Final.jar
│   ├── netty-handler-4.1.45.Final.jar
│   ├── netty-resolver-4.1.45.Final.jar
│   ├── netty-transport-4.1.45.Final.jar
│   ├── reactive-streams-1.0.3.jar
│   ├── reactor-core-3.3.3.RELEASE.jar
│   ├── reflections-0.9.9.jar
│   ├── scheduled-2.0.jar
│   ├── shiro-cache-1.5.1.jar
│   ├── shiro-config-core-1.5.1.jar
│   ├── shiro-config-ogdl-1.5.1.jar
│   ├── shiro-core-1.5.1.jar
│   ├── shiro-crypto-cipher-1.5.1.jar
│   ├── shiro-crypto-core-1.5.1.jar
│   ├── shiro-crypto-hash-1.5.1.jar
│   ├── shiro-event-1.5.1.jar
│   ├── shiro-lang-1.5.1.jar
│   ├── shiro-spring-1.5.1.jar
│   ├── shiro-web-1.5.1.jar
│   ├── slf4j-api-1.7.30.jar
│   ├── snakeyaml-1.26.jar
│   ├── spring-aop-5.2.4.RELEASE.jar
│   ├── spring-beans-5.2.4.RELEASE.jar
│   ├── spring-boot-2.2.5.RELEASE.jar
│   ├── spring-boot-actuator-2.2.5.RELEASE.jar
│   ├── spring-boot-actuator-autoconfigure-2.2.5.RELEASE.jar
│   ├── spring-boot-admin-client-2.2.2.jar
│   ├── spring-boot-admin-starter-client-2.2.2.jar
│   ├── spring-boot-autoconfigure-2.2.5.RELEASE.jar
│   ├── spring-boot-configuration-processor-2.2.5.RELEASE.jar
│   ├── spring-boot-starter-2.2.5.RELEASE.jar
│   ├── spring-boot-starter-actuator-2.2.5.RELEASE.jar
│   ├── spring-boot-starter-aop-2.2.5.RELEASE.jar
│   ├── spring-boot-starter-data-redis-2.2.5.RELEASE.jar
│   ├── spring-boot-starter-jdbc-2.2.5.RELEASE.jar
│   ├── spring-boot-starter-json-2.2.5.RELEASE.jar
│   ├── spring-boot-starter-logging-2.2.5.RELEASE.jar
│   ├── spring-boot-starter-tomcat-2.2.5.RELEASE.jar
│   ├── spring-boot-starter-validation-2.2.5.RELEASE.jar
│   ├── spring-boot-starter-web-2.2.5.RELEASE.jar
│   ├── spring-context-5.2.4.RELEASE.jar
│   ├── spring-context-support-5.2.4.RELEASE.jar
│   ├── spring-core-5.2.4.RELEASE.jar
│   ├── spring-data-commons-2.2.5.RELEASE.jar
│   ├── spring-data-keyvalue-2.2.5.RELEASE.jar
│   ├── spring-data-redis-2.2.5.RELEASE.jar
│   ├── spring-expression-5.2.4.RELEASE.jar
│   ├── spring-jcl-5.2.4.RELEASE.jar
│   ├── spring-jdbc-5.2.4.RELEASE.jar
│   ├── spring-oxm-5.2.4.RELEASE.jar
│   ├── spring-plugin-core-1.2.0.RELEASE.jar
│   ├── spring-plugin-metadata-1.2.0.RELEASE.jar
│   ├── spring-tx-5.2.4.RELEASE.jar
│   ├── spring-web-5.2.4.RELEASE.jar
│   ├── spring-webmvc-5.2.4.RELEASE.jar
│   ├── springfox-bean-validators-2.9.2.jar
│   ├── springfox-core-2.9.2.jar
│   ├── springfox-schema-2.9.2.jar
│   ├── springfox-spi-2.9.2.jar
│   ├── springfox-spring-web-2.9.2.jar
│   ├── springfox-swagger-common-2.9.2.jar
│   ├── springfox-swagger-ui-2.9.2.jar
│   ├── springfox-swagger2-2.9.2.jar
│   ├── swagger-annotations-1.5.20.jar
│   ├── swagger-models-1.5.20.jar
│   ├── system-2.0.jar
│   ├── tomcat-embed-core-9.0.31.jar
│   ├── tomcat-embed-el-9.0.31.jar
│   └── tomcat-embed-websocket-9.0.31.jar
└── logs
    ├── back
    ├── bootstrap-2.0.log
    ├── bootstrap-2.0_startup.log
    ├── spring-boot-plus-error.log
    └── spring-boot-plus.log

目录文件

  • lib:依赖jar包目录,高亮部分是项目jar包

# 设置数据库、Redis等敏感信息

修改对应环境的配置文件

vim config/application-dev.yml

# 启动日志

[root@springbootplus spring-boot-plus-1.2.0.RELEASE-prod]# sh spring-boot-plus/bin/startup.sh 
================================================ 2019-09-09 00:19:02 ================================================
application name: spring-boot-plus
application jar name: spring-boot-plus.jar
application bin path: /root/spring-boot-plus/target/spring-boot-plus-1.2.0.RELEASE-prod/spring-boot-plus/bin
application root path: /root/spring-boot-plus/target/spring-boot-plus-1.2.0.RELEASE-prod/spring-boot-plus
application log path: /root/spring-boot-plus/target/spring-boot-plus-1.2.0.RELEASE-prod/spring-boot-plus/logs/spring-boot-plus.log
application JAVA_OPT : -server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=256m -XX:-OmitStackTraceInFastThrow
application background startup command: nohup java -server -Xms1g -Xmx1g -Xmn512m -XX:MetaspaceSize=64m -XX:MaxMetaspaceSize=256m -XX:-OmitStackTraceInFastThrow -jar /root/spring-boot-plus/target/spring-boot-plus-1.2.0.RELEASE-prod/spring-boot-plus/lib/spring-boot-plus.jar --spring.config.location=/root/spring-boot-plus/target/spring-boot-plus-1.2.0.RELEASE-prod/spring-boot-plus/config/ > /root/spring-boot-plus/target/spring-boot-plus-1.2.0.RELEASE-prod/spring-boot-plus/logs/spring-boot-plus.log 2>&1 &
application pid: 25435


                 _                    _                 _                _
                (_)                  | |               | |              | |
  ___ _ __  _ __ _ _ __   __ _ ______| |__   ___   ___ | |_ ______ _ __ | |_   _ ___
 / __| '_ \| '__| | '_ \ / _` |______| '_ \ / _ \ / _ \| __|______| '_ \| | | | / __|
 \__ \ |_) | |  | | | | | (_| |      | |_) | (_) | (_) | |_       | |_) | | |_| \__ \
 |___/ .__/|_|  |_|_| |_|\__, |      |_.__/ \___/ \___/ \__|      | .__/|_|\__,_|___/
     | |                  __/ |                                   | |
     |_|                 |___/                                    |_|

      :: Spring Boot ::             (v2.1.8.RELEASE)
      :: Spring Boot Plus ::        (v1.2.3.RELEASE)
      :: spring-boot-plus ::        https://springboot.plus


2019-09-09 00:19:09.600  INFO 25435 --- [           main] i.g.s.SpringBootPlusApplication          : Starting SpringBootPlusApplication on izm5e9gwtfsmjdxcsrpxbgz with PID 25435 (/root/spring-boot-plus/target/spring-boot-plus-1.2.0.RELEASE-prod/spring-boot-plus/lib/spring-boot-plus.jar started by root in /root/spring-boot-plus/target/spring-boot-plus-1.2.0.RELEASE-prod/spring-boot-plus)
2019-09-09 00:19:09.962  INFO 25435 --- [           main] i.g.s.SpringBootPlusApplication          : The following profiles are active: prod

  • application name: 应用程序名称
  • application jar name: 应用jar包名称
  • application bin path: 项目bin命令路径
  • application root path: 项目根路径
  • application log path: 项目运行日志路径
  • application JAVA_OPT : JAVA OPT参数设置
  • application background startup command: 执行命令后,实际的启动命令
  • application pid: 进程ID
  • The following profiles are active: prod:prod当前项目运行的环境

# 启动成功

2019-09-09 00:29:05.730  INFO 26795 --- [           main] i.g.s.SpringBootPlusApplication          : Started SpringBootPlusApplication in 10.746 seconds (JVM running for 11.28)
2019-09-09 00:29:05.758  INFO 26795 --- [           main] i.g.s.util.PrintApplicationInfo          : projectFinalName : spring-boot-plus
2019-09-09 00:29:05.759  INFO 26795 --- [           main] i.g.s.util.PrintApplicationInfo          : projectVersion : 1.2.0.RELEASE
2019-09-09 00:29:05.759  INFO 26795 --- [           main] i.g.s.util.PrintApplicationInfo          : profileActive : prod
2019-09-09 00:29:05.759  INFO 26795 --- [           main] i.g.s.util.PrintApplicationInfo          : contextPath : /
2019-09-09 00:29:05.759  INFO 26795 --- [           main] i.g.s.util.PrintApplicationInfo          : port : 8888
2019-09-09 00:29:05.789  INFO 26795 --- [           main] i.g.s.util.PrintApplicationInfo          : home:http://172.31.105.37:8888/
2019-09-09 00:29:05.789  INFO 26795 --- [           main] i.g.s.util.PrintApplicationInfo          : docs:http://172.31.105.37:8888/docs
2019-09-09 00:29:05.789  INFO 26795 --- [           main] i.g.s.util.PrintApplicationInfo          : spring-boot-plus project start success...........
2019-09-09 00:29:05.795  INFO 26795 --- [           main] i.g.s.util.PrintApplicationInfo          : 
 ____    __                    __        ____                                                   
/\  _`\ /\ \__                /\ \__    /\  _`\                                                 
\ \,\L\_\ \ ,_\    __     _ __\ \ ,_\   \ \,\L\_\  __  __    ___    ___     __    ____    ____  
 \/_\__ \\ \ \/  /'__`\  /\`'__\ \ \/    \/_\__ \ /\ \/\ \  /'___\ /'___\ /'__`\ /',__\  /',__\ 
   /\ \L\ \ \ \_/\ \L\.\_\ \ \/ \ \ \_     /\ \L\ \ \ \_\ \/\ \__//\ \__//\  __//\__, `\/\__, `\
   \ `\____\ \__\ \__/.\_\\ \_\  \ \__\    \ `\____\ \____/\ \____\ \____\ \____\/\____/\/\____/
    \/_____/\/__/\/__/\/_/ \/_/   \/__/     \/_____/\/___/  \/____/\/____/\/____/\/___/  \/___/ 
                                                                                                
                                                                                                
2019-09-09 00:29:05.909  INFO 26795 --- [nio-8888-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2019-09-09 00:29:05.909  INFO 26795 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2019-09-09 00:29:05.926  INFO 26795 --- [nio-8888-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 15 ms
2019-09-09 00:29:06.317  INFO 26795 --- [gistrationTask1] d.c.b.a.c.r.ApplicationRegistrator       : Application registered itself as e211ba082db8
2019-09-09 00:29:06.678  INFO 26795 --- [     parallel-2] io.lettuce.core.EpollProvider            : Starting with epoll library
2019-09-09 00:29:06.681  INFO 26795 --- [     parallel-2] io.lettuce.core.KqueueProvider           : Starting without optional kqueue library
  • projectFinalName:spring-boot-plus
  • projectVersion:项目发布版本
  • profileActive:项目使用的环境
  • contextPath:项目访问路径
  • port:项目端口号
  • home:项目主页 Spring Boot Admin监控页面
  • docs:Swagger接口页面

WARNING

  • !! 注意,这里的路径是内网地址,如果部署到服务器,请使用公网IP访问!!

# 项目启动成功

spring-boot-plus project start success...........

  • 如有疑问,欢迎加群讨论:625301326