开发者

Eclipse Project with Dependency Management by Maven

I have a Eclipse project where Maven manages the dependencies. I have also few jar files that are not Maven enable and I locate them at src/main/webapp/WEB-INF/lib. I have no issue to build/run the projec开发者_开发知识库t in Eclipse. I have no issue also to run "mvn:package" after I built the project in Eclipse. However, after I invoke "mvn:clean", if I run "mvn:package", I will get compilation error as it can't find dependency jar files under src/main/webapp/WEB-INF/lib. What I need to do is to rebuild the Eclipse project then "mvn:package". Therefore, I can't invoke "mvn:package" outside Eclipse IDE.

How to resolve this?

Thanks.


You have to put the not "Maven enabled artifacts" to an appropriate Maven Repository (Nexus, Artifactory what ever) and than change your project to use the dependencies appropriately. Furthermore either you do Maven or not but nothing in between. Maven is a build tool and not only for dependency management. After those changes working with Eclipse will work fine (if you use M2Eclipse). If you correctly use Maven you can do both things via Eclipse or call mvn package on command line.


If you can not set up a recommended environment (maven repository) you can add the dependencies as System dependencies to your pom.xml.

<project>
  ...
  <dependencies>
    <dependency>
      <groupId>foo</groupId>
      <artifactId>bar</artifactId>
      <version>1.2.3</version>
      <scope>system</scope>
      <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/foobar.jar</systemPath>
    </dependency>
  </dependencies>
  ...
</project>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜