在开发项目时,有些 jar 包是非 maven 仓库提供的第三方 jar 包,比如七牛的 sdk,阿里的 sdk 等等。
在项目开发时,有以下两个方案来引入、打包。
先决条件
jar 包路径:src/main/resources/lib/*.jar
例子
jar 包路径:src/main/resources/lib/cachejdbc.jar
jar 包以 scope 为 system 的方式导入 pom 文件
1 2 3 4 5 6 7
| <dependency> <groupId>com.intersys.jdbc</groupId> <artifactId>CacheDriver</artifactId> <version>2016.2</version> <scope>system</scope> <systemPath>${project.basedir}/src/main/resources/lib/cachejdbc.jar</systemPath> </dependency>
|
jar 包配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>repackage</goal> </goals> </execution> </executions> <configuration> <includeSystemScope>true</includeSystemScope> </configuration> </plugin> </plugins> </build>
|
war 包配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-war-plugin</artifactId> <configuration> <webResources> <resource> <directory>src/main/resources/lib/</directory> <targetPath>WEB-INF/lib</targetPath> <includes> <include>**/*.jar</include> </includes> </resource> </webResources> </configuration> </plugin> </plugins> </build>
|