一、在使用springboot框架的时候,存在一个问题。就是我们配置yaml文件,需要单独提出来做参数修改。当然这个是可以通过spring.profiles.active的方式来配置dev,prod等环境的激活。但是我们如果存在环境不确定,或者需要启动脚本,启动项目的时候,这样通过jar的方式后续会处理很多工作。所以前期的集成工作还是很有必要的。

  二、这里有一个简单的例子,用于参数配置方式

  1)目录结构

  

  2)需要的依赖包(pom.xml)

  <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.RELEASE</version>
</parent> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

  3)maven的构建过程

   <build>
<finalName>assembly</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<plugin>
<!--主要使用的是maven提供的assembly插件完成-->
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<!--具体的配置文件-->
<descriptors>${project.basedir}/src/main/resources/assembly/package.xml</descriptors>
</configuration>
<id>make-assembly</id>
<!--绑定到maven操作类型上-->
<phase>package</phase>
<!--运行一次-->
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

  4)集成过程(package.xml)

<?xml version='1.0' encoding='UTF-8'?>
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<!--打包名称,唯一标识-->
<id>${project.build.finalName}</id>
<!--打包格式,可以手动修改-->
<formats>
<format>tar.gz</format>
</formats>
<!--文件设置-->
<fileSets>
<fileSet>
<!--目标目录,会处理目录里面的所有文件-->
<directory>${project.basedir}/src/main/resources/config</directory>
<!--相对于打包后的目录-->
<outputDirectory>config</outputDirectory>
<!--文件过滤-->
<includes>
<include>*.*</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.basedir}/src/main/resources/script</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>*.*</include>
</includes>
<!--文件权限-->
<fileMode>0755</fileMode>
<!--如果是脚本,一定要改为unix.如果是在windows上面编码,会出现dos编写问题-->
<lineEnding>unix</lineEnding>
</fileSet>
</fileSets>
<files>
<!--包含打包后的jar文件,可以不加入<outputDirectory/>,默认打包的目录-->
<file>
<source>${project.build.directory}/${project.build.finalName}.jar</source>
</file>
<!--这种方式也可以进行文件处理,但是针对单文件-->
<!-- <file>
<source>${project.basedir}/src/main/resources/script/start.sh</source>
<fileMode>0755</fileMode>
<lineEnding>unix</lineEnding>
</file>-->
</files>
</assembly>

  备注:具体的参数的意义可以参考官网:http://maven.apache.org/plugins/maven-assembly-plugin/assembly.html

  5)通过maven的package打包

  

  

  

  三、源码:https://github.com/lilin409546297/springboot-assembly

springboot之assembly的文件配置的更多相关文章

  1. SpringBoot入门-多环境文件配置(二)

    pom.xml <name>springboot-application</name> <description>A project for Spring Boot ...

  2. SpringBoot中自定义properties文件配置参数并带有输入提示

    1. 创建配置类 在项目中创建一个参数映射类如下 @ConfigurationProperties(prefix = "user.info") public class MyPro ...

  3. 【2.0】SpringBoot多环境yml文件配置

    一.使用Spring Boot Profiles 1. 使用yml文件 首先,我们先创建一个名为 application.yml的属性文件,如下: server: port: 8080 my: nam ...

  4. Spring-Boot注入自定义properties文件配置

    创建wzq.properties wzq.properties注入User实体类中 @PropertySource(value = "classpath:wzq.properties&quo ...

  5. SpringBoot 项目打包分开lib,配置和资源文件

    原文地址:https://blog.csdn.net/u012811805/article/details/80878848 1 jar启动分离依赖lib和配置 先前发布boot项目的时候,改动一点东 ...

  6. ******可用 SpringBoot 项目打包分开lib,配置和资源文件

    spring-boot多模块打包后,无法找到其他模块中的类https://blog.csdn.net/Can96/article/details/96172172 关于SpringBoot项目打包没有 ...

  7. 在springboot pom文件配置过程,`spring-boot-maven-plugin`配置出错的问题解决及配置过程出现问题的一些思考

    在springboot pom文件配置过程,spring-boot-maven-plugin配置出错的问题解决及配置过程出现问题的一些思考 解决方法一: 也是最简单的方法,可能是maven没有来得及导 ...

  8. SpringBoot多重属性文件配置方案笔记

    SpringBoot多重属性文件配置方案笔记 需要重写PropertyPlaceholderConfigurer 同时要忽略DataSourceAutoConfiguration @SpringBoo ...

  9. Springboot多属性文件配置

    Springboot 多属性文件配置 配置文件后缀有两种: .properties和.yml 要完成多属性配置需要自定义PropertySourcesPlaceholderConfigurer 这个B ...

随机推荐

  1. 如何在 OS X 中安装 ruby

    如何在 OS X 中安装 ruby 软件包下载 链接: http://pan.baidu.com/s/1mgMil5I 密码: tiqg 安装 http://brew.sh/ 1. 先安装 brew( ...

  2. java.lang.verifyerror:bad type on orerand stack

    问题: junit测试的时候报这个错:java.lang.verifyerror:bad type on orerand stack 原因:(多种,自行逐个排查) 1.class not find 引 ...

  3. asp.net mvc文件下载

    一.zip打包下载 1.依赖引用:ICSharpCode.SharpZipLib 2.设定网站有单独文件服务器,网站目录下有虚拟路径FileFolder,通过虚拟路径将文件映射到文件服务器. 设定根据 ...

  4. UI(一)

    1.AfxWinMain 首先,MFC程序先执行到TheApp实例化对象也就是通过这句CTestApp the App来实例化对象的然后,调用CTestApp构造函数分配内存空间 然后,就调用了Afx ...

  5. 个人作业2——集大通APP案例分析

    个人作业2——集大通APP案例分析 产品:集大通 我认为这个是我们学校的APP,我们应该支持一下. 一.个人体验 1.下载并使用,描述最简单直观的个人第一次上手体验. ①界面美观,可以感受到丰富的校园 ...

  6. jquery环形3D立体旋转特效

      jquery环形3D立体旋转特效 作者/代码整理:站长素材  (转载请附加本文地址,带有“懒人原生”字样的谢绝转载)发布日期:2013-07-20   立体效果比较强的jquery特效,周围小图组 ...

  7. 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 F题 Clever King(最小割)

    2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...

  8. 看懂shebang吧,只需一点点shell知识,从此再也不犯强迫症

    Python2: 开启一个terminal,输入下面命令: yshuangj@ubuntu:~$ vim helloA.py 在vim编辑器中,进入编辑模式(按i),输入下面的代码,然后退出编辑模式( ...

  9. ASP.NET MVC编程——路由

    框架自动生成的路由配置 上图中,路由配置文件为App_Start文件夹下的RouteConfig.cs. 代码如下: public class RouteConfig { public static ...

  10. transfer function

    线性变化后,往往希望进行非线性变化,常用的非线性变化函数有Sigmoid,Tanh,ReLU.会发现,经过这三个函数变化后,Tensor的维度并不发生变化. tanh(双曲正切函数):