一.每次用maven的打包工具打包的时候 总是将配置文件一起打包进jar中!配置文件有点小修改就要重新打包很麻烦!!!!为了解决这一麻烦!找 了很多方法,下面的配置已经实现可用

我的项目目录结构如下

1.pom.xml中的配置

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.springframework.boot</groupId>
  5. <artifactId>spring-boot-maven-plugin</artifactId>
  6. </plugin>
  7. <plugin>
  8. <groupId>org.apache.maven.plugins</groupId>
  9. <artifactId>maven-jar-plugin</artifactId>
  10. <configuration>
  11. <archive>
  12. <manifest>
  13. <addClasspath>true</addClasspath>
  14. <classpathPrefix></classpathPrefix>
  15. <mainClass>com.cn.Application</mainClass>
  16. </manifest>
  17. </archive>
  18. </configuration>
  19. </plugin>
  20. <plugin>
  21. <groupId>org.apache.maven.plugins</groupId>
  22. <artifactId>maven-assembly-plugin</artifactId>
  23. <!-- The configuration of the plugin -->
  24. <configuration>
  25. <!-- Specifies the configuration file of the assembly plugin -->
  26. <descriptors>
  27. <descriptor>src/main/assembly/package.xml</descriptor>
  28. </descriptors>
  29. </configuration>
  30. <executions>
  31. <execution>
  32. <id>make-assembly</id>
  33. <phase>package</phase>
  34. <goals>
  35. <goal>single</goal>
  36. </goals>
  37. </execution>
  38. </executions>
  39. </plugin>
  40. </plugins>
  41. <resources>
  42. <resource>
  43. <directory>src/main/java</directory>
  44. <includes>
  45. <include>**/*.xml</include>
  46. </includes>
  47. <filtering>false</filtering>
  48. </resource>
  49. <resource>
  50. <directory>src/main/resources</directory>
  51. </resource>
  52. <resource>
  53. <directory>lib/</directory>
  54. <targetPath>lib</targetPath>
  55. <includes>
  56. <include>**/*.jar</include>
  57. </includes>
  58. </resource>
  59. </resources>
  60. </build>

在上面的配置中使用了一下两个工具

maven-jar-plugin,负责将应用程序打包成可执行的jar文件 
maven-assembly-plugin,负责将整个项目按照自定义的目录结构打成最终的压缩包,方便实际部署

2.package.xml的配置如下

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <assembly
  3. xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
  6. <id>package</id>
  7. <formats>
  8. <format>zip</format>
  9. </formats>
  10. <includeBaseDirectory>true</includeBaseDirectory>
  11. <fileSets>
  12. <!-- 把项目相关的说明文件,打包进zip文件的根目录 -->
  13. <fileSet>
  14. <directory>${project.basedir}</directory>
  15. <outputDirectory>/</outputDirectory>
  16. <includes>
  17. <include>README*</include>
  18. <include>LICENSE*</include>
  19. <include>NOTICE*</include>
  20. <include>build.info</include>
  21. </includes>
  22. </fileSet>
  23.  
  24. <fileSet>
  25. <directory>${project.basedir}/config</directory>
  26. <outputDirectory>config</outputDirectory>
  27. <includes>
  28. <include>*.properties</include>
  29. <include>ireport/*.jasper</include>
  30. </includes>
  31. </fileSet>
  32.  
  33. <!-- 把项目自己编译出来的jar文件,打包进zip文件的根目录 -->
  34. <fileSet>
  35. <directory>${project.build.directory}</directory>
  36. <outputDirectory>/</outputDirectory>
  37. <includes>
  38. <include>*.jar</include>
  39. </includes>
  40. </fileSet>
  41. </fileSets>
  42. </assembly>

SpringBoot中打包设置,将配置文件打包在外部的更多相关文章

  1. Springboot中IDE支持两种打包方式,即jar包和war包

    Springboot中IDE支持两种打包方式,即jar包和war包 打包之前修改pom.xml中的packaging节点,改为jar或者war    在项目的根目录执行maven 命令clean pa ...

  2. springboot中使用@Value读取配置文件

    一.配置文件配置 直接配置 在src/main/resources下添加配置文件application.properties 例如修改端口号 #端口号 server.port=8089 分环境配置 在 ...

  3. Java启动命令与Maven打包设置

    一.Java启动命令 java程序的启动方式有三种: 1.java -jar 生成的jar包中,manifest文件定义了Main Class,可使用该命令 java -jar test.jar 2. ...

  4. vue中打包生成可配置文件以便修改接口地址

    vue打包上传到服务器之后,如果数据接口域名发生变化,需要手动修改接口地址,在发布的时候也麻烦,于是.. 在打包之后如果有一个json配置文件以便修改那不是方便很多 在网上找了一些方法貌似都是异步请求 ...

  5. 【转】Maven项目中将配置文件打包到jar包中

    参考博客:http://blog.csdn.net/ciedecem/article/details/10382275 问题: 项目中需要用到从文件中加载json数据,如图放在conf目录下. 程序中 ...

  6. InstallShield打包设置相对路径

    InstallShield打包设置相对路径 在使用Installshield 打包安装文件时,添加打包文件时默认使用绝对路径,但是工程文件转移时(复制到其它位置时)编译时就会找不到安装文件,这样很不方 ...

  7. springboot学习之maven多环境打包的几种方式

    在应用部署的时候,往往遇到需要发布到不同环境的情况,而每个环境的数据库信息.密钥信息等可能会存在差异. 1.在默认的application.properties或者yaml中设置profile spr ...

  8. maven根据不同的运行环境,打包不同的配置文件

    使用maven管理项目中的依赖,非常的方便.同时利用maven内置的各种插件,在命令行模式下完成打包.部署等操作,可方便后期的持续集成使用. 但是每一个maven工程(比如web项目),开发人员在开发 ...

  9. maven根据不同的运行环境,打包不同的配置文件(转载)

    使用maven管理项目中的依赖,非常的方便.同时利用maven内置的各种插件,在命令行模式下完成打包.部署等操作,可方便后期的持续集成使用. 但是每一个maven工程(比如web项目),开发人员在开发 ...

  10. coding++:maven根据不同的运行环境,打包不同的配置文件

    1.使用maven管理项目中的依赖,非常的方便.同时利用maven内置的各种插件,在命令行模式下完成打包.部署等操作,可方便后期的持续集成使用. 2.但是每一个maven工程(比如web项目),开发人 ...

随机推荐

  1. solrj 操作 solr 集群版

    一.添加 @Test public void testAddDocument() throws Exception{ //创建一个集群的连接,应该使用 CloudSolrServer,//zkHost ...

  2. oracle double和float,number

    float,double,number都是oracle的数值类型.1个汉子=2个英文=2个字节float表示单精度浮点数在机内占4个字节,用32位二进制描述. double表示双精度浮点数在机内占8个 ...

  3. ASP.NET CORE--WIN10上无法单步调试解决方法

    参考这篇文章 http://www.cnblogs.com/artech/p/debug-in-vs-code.html In order to be able to debug cross-plat ...

  4. C#-WinForm中文本框的中文乱码问题

    上面这句话可以解决textbox中的中文乱码问题   来自为知笔记(Wiz) 附件列表 QQ图片20151218124007.png

  5. chrome隐身模式无法播放flash的解决办法

    困扰很多天的chrome无法播放flash的问题终于解决了 因为之前一直用隐身模式,一直不能播放flash,重装chrome,重装插件,还是不行 结果今天发现正常模式是可以播放的,所以找了一下chro ...

  6. 12. mysql show status

    状态名 作用域 详解 Aborted_clients Global 因为client没有正确关闭连接导致client终止而中断的连接数 Aborted_connects Global 试图连接到MyS ...

  7. asf

    这些日子我一直在写一个实时操作系统内核,已有小成了,等写完我会全部公开,希望能  够为国内IT的发展尽自己一份微薄的力量.最近看到很多学生朋友和我当年一样没有方向  ,所以把我的经历写出来与大家共勉, ...

  8. 关于getElementsByTagName的遍历顺序

    关于getElementsByTagName的遍历顺序是怎么样的呢? getElementsByTagName的遍历顺序是从HTML的页面从上到下遍历还是按照标签的嵌套顺序层层遍历的呢? 来做个小小的 ...

  9. DirectUI界面编程(五)WindowImplBase的使用

    上节笔者向大家介绍了Duilib的界面布局并在最后编写了一个仿QQ旋风的界面,但是由于我们屏蔽了系统的标题栏,读者可能已经发现,我们的窗口没办法移动,同样也不能通过拖动来改变窗口的大小. 这就需要我们 ...

  10. 让html页面不缓存js的实现方法

    很多朋友都会碰到这样的情况:如果我们页面加载了js的话下次打开时也会是调用这个js缓存文件,但对于我们调试时是非常的不方便了,本文就来谈论如何解决这一问题,下面一起来看看. 不缓存JS的方法其实挺简单 ...