使用systemPath解决依赖问题

注意!使用systemPath的依赖在打包时一般不会被收录,需要配合插件完成打包。这里使用的是spring-boot-maven-plugin。

思路

  • 指定依赖的scope为system
  • 指定依赖的systemPath为 ${pom.basedir}/jar包路径 ,其中 ${pom.basedir} 是项目根路径
  • 配置spring-boot-maven-plugin的includeSystemScope为true,收录本地jar包

    示例

    只有部分小节,使用时注意层级 ```xml org.json.simple json-simple 1.1.1 system ${pom.basedir}/libs/json-simple-1.1.1.jar com.xiaomi com.xiaomi 2.2.21 system ${pom.basedir}/libs/MiPush_SDK_Server_2_2_21.jar

……

org.springframework.boot spring-boot-maven-plugin true true

  1. <a name="HdXeM"></a>
  2. ## 使用maven-install-plugin插件解决问题(未验证)
  3. <a name="xTKqo"></a>
  4. ### 思路
  5. - 引入一个插件,绑定一个命令,这个命令可以把本地jar包安装到本地仓库中
  6. - 基本可以认为是mvn install的自动版
  7. - 如果绑定到生命周期,应该可以完全自动化
  8. <a name="5HMmk"></a>
  9. ### 示例
  10. ```xml
  11. <dependency>
  12. <groupId>org.jbarcode</groupId>
  13. <artifactId>jbarcode</artifactId>
  14. <version>0.2.8</version>
  15. </dependency>
  16. ......
  17. <plugin>
  18. <groupId>org.apache.maven.plugins</groupId>
  19. <artifactId>maven-install-plugin</artifactId>
  20. <version>2.5.2</version>
  21. <executions>
  22. <execution>
  23. <id>install-external</id>
  24. <phase>clean</phase>
  25. <configuration>
  26. <file>${basedir}/web/WEB-INF/lib/jbarcode-0.2.8.jar</file>
  27. <repositoryLayout>default</repositoryLayout>
  28. <groupId>org.jbarcode</groupId>
  29. <artifactId>jbarcode</artifactId>
  30. <version>0.2.8</version>
  31. <generatePom>true</generatePom>
  32. </configuration>
  33. <goals>
  34. <goal>install-file</goal>
  35. </goals>
  36. </execution>
  37. </executions>
  38. </plugin>