将spring boot的application配置打包到 生成的jar文件的同级 目录下

 直接 在 pom 文件中添加 以下 插件:


  
  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. <outputDirectory>${project.build.directory}</outputDirectory>
  12. <excludes>
  13. <exclude>application-dev.yml</exclude>
  14. <exclude>application-prod.yml</exclude>
  15. <exclude>application.yml</exclude>
  16. </excludes>
  17. </configuration>
  18. </plugin>
  19. <!--&lt;!&ndash; maven资源文件复制插件 &ndash;&gt;-->
  20. <plugin>
  21. <groupId>org.apache.maven.plugins</groupId>
  22. <artifactId>maven-resources-plugin</artifactId>
  23. <version>3.1.0</version>
  24. <executions>
  25. <execution>
  26. <id>copy-resources</id>
  27. <!-- here the phase you need -->
  28. <phase>package</phase>
  29. <goals>
  30. <goal>copy-resources</goal>
  31. </goals>
  32. <configuration>
  33. <outputDirectory>${project.build.directory}</outputDirectory>
  34. <resources>
  35. <resource>
  36. <directory>src/main/resources</directory>
  37. <includes>
  38. <exclude>application-dev.yml</exclude>
  39. <exclude>application-prod.yml</exclude>
  40. <exclude>application.yml</exclude>
  41. </includes>
  42. <filtering>true</filtering>
  43. </resource>
  44. </resources>
  45. <encoding>UTF-8</encoding>
  46. </configuration>
  47. </execution>
  48. </executions>
  49. </plugin>
  50. </plugins>
  51. </build>

执行 mvn clean package -DskipTests 命令 即可 

 

 

文章来源: blog.csdn.net,作者:血煞风雨城2018,版权归原作者所有,如需转载,请联系作者。

原文链接:blog.csdn.net/qq_31905135/article/details/89227622

(完)