springboot添加外部jar包及打包
项目中除了从pom中添加依赖包,还可以添加本地的jar包,怎么做呢?
1、在src下新建目录lib,将jar包添加到lib中
2、在pom文件里添加配置以下属性,就可以使用jar包了
1 <dependency> 2 <groupId>alidao-jxe</groupId> 3 <artifactId>alidao-jxe</artifactId> 4 <version>1.0</version> 5 <scope>system</scope> 6 <systemPath>${basedir}/src/lib/alidao-jxe-6-1.0.0.jar</systemPath> 7 </dependency>
3、如果打包jar,就需要再配置下,如下,关键最后个resource
1 <build> 2 <plugins> 3 <plugin> 4 <groupId>org.apache.maven.plugins</groupId> 5 <artifactId>maven-compiler-plugin</artifactId> 6 </plugin> 7 <plugin> 8 <groupId>org.springframework.boot</groupId> 9 <artifactId>spring-boot-maven-plugin</artifactId> 10 </plugin> 11 </plugins> 12 <resources> 13 <resource> 14 <directory>src/main/webapp</directory> 15 </resource> 16 <resource> 17 <directory>src/main/resources</directory> 18 </resource> 19 <resource> 20 <directory>src/main/java</directory> 21 <includes> 22 <include>**/*.xml</include> 23 </includes> 24 </resource> 25 <resource> 26 <directory>src/lib</directory> 27 <targetPath>BOOT-INF/lib/</targetPath> 28 <includes> 29 <include>**/*.jar</include> 30 </includes> 31 </resource> 32 </resources> 33 </build>
4、执行打包,完成