[Mavne] Maven项目引入非Maven的jar

原创
2017/04/22 11:37
阅读数 560

背景

最新项目引入了对接其他项目,但是其他项目提供的jar不是mvn的,所以每次mvn编译都是失败

解决方式

将非Maven的jar通过下面方式定义的项目的pmo文件

<dependency>
    <groupId>cn.xxx</groupId>
    <artifactId>xxx</artifactId>
    <version>2.0</version>
    <scope>system</scope>
    <systemPath>${project.basedir}/lib/xxx.jar</systemPath>
</dependency>

说明:

  systemPath:jar包的路径

修改maven的编译插件:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <version>2.5</version>
    <configuration>
        <warName>${project.artifactId}</warName>
        <webResources>
            <resource>
                <directory>lib/</directory>
                <targetPath>WEB-INF/lib</targetPath>
                <includes>
                    <include>**/*.jar</include>
                </includes>
            </resource>
        </webResources>
    </configuration>
</plugin>
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-compiler-plugin</artifactId>
  <version>3.2</version>
  <configuration>
      <source>1.7</source>
      <target>1.7</target>
      <encoding>utf-8</encoding>
      <debug>true</debug>
      <fork>true</fork>
      <compilerArguments>
          <extdirs>src\main\webapp\WEB-INF\lib</extdirs>
      </compilerArguments>
  </configuration>
</plugin>

 

展开阅读全文
加载中
点击引领话题📣 发布并加入讨论🔥
打赏
0 评论
1 收藏
0
分享
返回顶部
顶部