maven打包为jar文件时,解决scope为system的jar包无法被打包进jar文件的解决方案。(When Maven is packaged as a jar file, the jar package with scope system cannot be packaged into a jar file.)

scope为system的maven默认是不打包进去的。

网上查了很多解决方案,基本都是错误的,特别是中文社区,基本没有说到点上的。配置resource的,更容易导致其他问题。

最后,翻到github上的spring-projects/spring-boot的issue里,终于找到了正确的解决之道。

很简单。

1
2
3
4
5
6
7
<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration>
    <includeSystemScope>true</includeSystemScope>
  </configuration>
</plugin>

 

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>
true
</includeSystemScope>
</configuration>
</plugin>
————————

Maven with scope system is not packaged by default.

Many solutions have been found online, but they are basically wrong, especially in the Chinese community. Configuring resource is more likely to cause other problems.

Finally, turn to the issue of spring projects / spring boot on GitHub and finally find the right solution.

It’s simple.

1
2
3
4
5
6
7
<plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  <configuration>
    <includeSystemScope>true</includeSystemScope>
  </configuration>
</plugin>

 

<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>
true
</includeSystemScope>
</configuration>
</plugin>