maven工程导入本地jar包的一种方式

在pom.xml文件中添加以下内容

<dependency>
<groupId>RXTX</groupId>
<artifactId>RXTX</artifactId>
<version>2.2-20081207</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/webapp/lib/RXTXcomm.jar</systemPath>
</dependency>
注意:
  • groupId:自定义
  • artifactId:自定义
  • version:自定义
  • scope:必须是system
  • systemPath:jar包的路径;
    ${project.basedir}表示当前工程相对路径,只需在后面加上你的jar包即可

 

在pom.xml文件的打包内容部分添加以下内容,

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${project.basedir}/src/main</directory>
<targetPath>webapp/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</resource>
</webResources>
</configuration>
</plugin>


  • directory:指定jar存放文件夹的位置,以自己的存放目录为准
  • targetPath:打包到的文件夹位置,
  • includes:一般都是以jar结尾,就写**/*.jar

最后打包即可。

posted @ 2022-02-15 12:04  蝴蝶梦南华  阅读(188)  评论(0)    收藏  举报