本文源码:GitHub·点这里 || GitEE·点这里

一、打包简介

springboot的打包方式有很多种。可以打war包,可以打jar包,可以使用jekins进行打包部署的。不推荐用war包,SpringBoot适合前后端分离,打成jar进行部署更加方便快捷。

二、自定义启动页



banner.txt内容

=======================
No BUG
=======================

这样就替换了原先SpringBoot的启动样式。

三、打包配置

1、打包pom配置

<!-- 项目构建 -->
<build>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<!-- SpringBoot插件:JDK编译插件 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<!-- SpringBoot插件:打包 -->
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<jvmArguments>-Dfile.encoding=UTF-8</jvmArguments>
<executable>true</executable>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- 跳过单元测试 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>true</skipTests>
</configuration>
</plugin>
</plugins>
</build>

2、多环境配置

1)application.yml配置

server:
port: 8017
spring:
application:
name: node17-boot-package
profiles:
active: dev

2)application-dev.yml配置

project:
sign: develop

3)application-pro.yml配置

project:
sign: product

3、环境测试接口

package com.boot.pack.controller;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class PackController {
@Value("${project.sign}")
private String sign ;
@RequestMapping("/getSign")
public String getSign (){
return sign ;
}
}

四、打包执行

1、指定模块打包

mvn clean install -pl node17-boot-package -am -Dmaven.test.skip=true
生成Jar包:node17-boot-package.jar

2、运行Jar包

运行dev环境

java -jar node17-boot-package.jar --spring.profiles.active=dev

运行pro环境

java -jar node17-boot-package.jar --spring.profiles.active=pro

http://localhost:8017/getSign
dev环境打印:develop
pro环境打印:product

五、源代码地址

GitHub·地址
https://github.com/cicadasmile/spring-boot-base
GitEE·地址
https://gitee.com/cicadasmile/spring-boot-base

SpringBoot2.0 基础案例(17):自定义启动页,项目打包和指定运行环境的更多相关文章

  1. 十六:SpringBoot-自定义启动页,项目打包和指定运行环境

    SpringBoot-自定义启动页,项目打包和指定运行环境 1.自定义启动页 2.打包配置 2.1 打包pom配置 2.2 多环境配置 3.环境测试接口 4.打包执行 4.1 指定模块打包 4.2 运 ...

  2. SpringBoot2.0 基础案例(12):基于转账案例,演示事务管理操作

    本文源码 GitHub地址:知了一笑 https://github.com/cicadasmile/spring-boot-base 一.事务管理简介 1.事务基本概念 一组业务操作ABCD,要么全部 ...

  3. SpringBoot2.0 基础案例(13):基于Cache注解模式,管理Redis缓存

    本文源码 GitHub地址:知了一笑 https://github.com/cicadasmile/spring-boot-base 一.Cache缓存简介 从Spring3开始定义Cache和Cac ...

  4. SpringBoot2.0 基础案例(03):配置系统全局异常映射处理

    一.异常分类 这里的异常分类从系统处理异常的角度看,主要分类两类:业务异常和系统异常. 1.业务异常 业务异常主要是一些可预见性异常,处理业务异常,用来提示用户的操作,提高系统的可操作性. 常见的业务 ...

  5. SpringBoot2.0基础案例(01):环境搭建和RestFul风格接口

    一.SpringBoot 框架的特点 1.SpringBoot2.0 特点 1)SpringBoot继承了Spring优秀的基因,上手难度小 2)简化配置,提供各种默认配置来简化项目配置 3)内嵌式容 ...

  6. SpringBoot2.0 基础案例(14):基于Yml配置方式,实现文件上传逻辑

    本文源码 GitHub地址:知了一笑 https://github.com/cicadasmile/spring-boot-base 一.文件上传 文件上传是项目开发中一个很常用的功能,常见的如头像上 ...

  7. SpringBoot2.0 基础案例(09):集成JPA持久层框架,简化数据库操作

    一.JAP框架简介 JPA(Java Persistence API)意即Java持久化API,是Sun官方在JDK5.0后提出的Java持久化规范.主要是为了简化持久层开发以及整合ORM技术,结束H ...

  8. SpringBoot2.0 基础案例(16):配置Actuator组件,实现系统监控

    本文源码 GitHub地址:知了一笑 https://github.com/cicadasmile/spring-boot-base 一.Actuator简介 1.监控组件作用 在生产环境中,需要实时 ...

  9. SpringBoot2.0 基础案例(04):定时任务和异步任务的使用方式

    一.定时任务 1.基本概念 按照指定时间执行的程序. 2.使用场景 数据分析 数据清理 系统服务监控 二.同步和异步 1.基本概念 同步调用 程序按照代码顺序依次执行,每一行程序都必须等待上一行程序执 ...

随机推荐

  1. Internet History,Technology,and Security - Technology: Internets and Packets (Week5)

    Week5 Technology: Internets and Packets Welcome to Week 5! This week, we’ll be covering internets an ...

  2. BOM对象——History

    BOM对象--History <!DOCTYPE html> <html> <head> <meta charset="utf-8"> ...

  3. Hack the 21LTR: Scene 1 VM (Boot to Root)

    靶机下载链接: https://www.vulnhub.com/entry/21ltr-scene-1,3/ 主机扫描: ╰─ nmap -p1-65535 -sV -sC -A  192.168.2 ...

  4. IOS弓箭传说的插件开发

    1.导出ipa进行解压后,定位到执行程序archero,ida加载后,发现很多都是sub_xxx开头的. 2.搜索资料后,原来Unity编写的程序,可以使用Il2CppDumper进行符号表还原. 下 ...

  5. Bash脚本编程之脚本基础和bash配置文件

    脚本基础 参考资料:Shell Scripts (Bash Reference Manual) 不严谨地说,编程语言根据代码运行的方式,可以分为两种方式: 编译运行:需要先将人类可识别的代码文件编译成 ...

  6. gdisk转fdisk

    分区测试的时候发现之前用gdisk分区之后,就无法用fdisk进行分区了,哪怕格式化了也不行,通过fdisk 查看硬盘,发现硬盘都变成了GPT分区,无法通过fdisk进行分区操作,所以要通过parte ...

  7. js new Date 创建时间默认是8点

    起因 最近在写一个页面,需要用到时间控制.然后我通过new Date()传入日期字符串创建了一个对象,并与当前时间做时间戳比较,结果12点刚过,就出问题了.举个栗子 // 假设当前时间是2019年12 ...

  8. Java设计模式13:责任链模式

    前言 来菜鸟这个大家庭10个月了,总得来说比较融入了环境,同时在忙碌的工作中也深感技术积累不够,在优秀的人身边工作必须更加花时间去提升自己的技术能力.技术视野,所以开一个系列文章,标题就轻松一点叫做最 ...

  9. C# Newtonsoft.Json JsonSerializerSettings配置

    JsonSerializerSettings常用配置整理 1.忽略某些属性 MemberSerialization.OptIn 默认情况下,所有的成员不会被序列化,类中的成员只有标有特性JsonPro ...

  10. spring-boot 再添加mysql启动器的时候报错, The driver is automatically registered via the SPI and manual loading of the driver class....

    mysql驱动更新迭代之后驱动,稍微有点变化: com.mysql.jdbc.Driver (变化为) --> driver-class-name: com.mysql.cj.jdbc.Driv ...