可以通过eclipse(和m2e)的方式来处理WEB-INF \lib吗? [英] Can maven treat WEB-INF\lib the way eclipse (and m2e) does?

查看:264
本文介绍了可以通过eclipse(和m2e)的方式来处理WEB-INF \lib吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个servlet / jsp web项目,它在eclipse上运行良好,并被导出为war罚款(一旦我清理它就是)。我把这个项目从除了一个homebrew jar 之外的 WEB-INF \lib 文件夹(删除所有依赖项)工作区)。当我运行 maven目标时,我会收到来自此jar的缺少类的消息:

  [错误]编译错误:
[INFO] --------------------------------- ----------------------------
#.....注意这是一个自定义JAR
[错误] /C:/path/DataServlet.java:[3,30] package xxx.java.helpers不存在

现在已经被问到之前,最严格的解决方案似乎是创建一个本地的回购:我可以添加jar到maven 2构建类路径而不安装它们吗?(注意:我在maven 3 )。



我想避免这一点 - 所以有什么方法,maven将只是将这个jar填充到$ code> WEB-INF \lib war



使用一些maven插件的解决方案 cp 欢迎战争中 WEB-INF \lib 的内容 - 虽然我只是有这样的感觉应该有一个解决方案,考虑到这个文件夹的特殊性质。



观察:




  • Alt + F5删除此行:

      classpathentry kind =conpath =org.eclipse.jst.j2ee.internal.web.container/> 

    它对应于Java Build Path中的Web App库。所以不仅maven拒绝考虑到 WEB-INF \lib - 它也会完全打破eclipse的构建路径。




相关:




解决方案

您是否将WEB-INF \lib中的jar添加为依赖关系:

  <依赖性> 
< groupId> someGroupId< / groupId>
< artifactId> someArtifactId< / artifactId>
< version> 1.0.0< / version>
< scope> system< / scope>
< systemPath> $ {basedir} / src / main / webapp / WEB-INF / lib / homebrew jar< / systemPath>
< / dependency>


I have a servlet/jsp web project which runs fine on eclipse and is exported as war fine (once I clean it that is). I mavenized the project deleting all of the dependencies from the WEB-INF\lib folder except a homebrew jar (the output of another project in the workspace). When I run the package maven goal I get messages for missing classes from this jar:

[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
#..... NOTICE THIS COMES FROM A CUSTOM JAR
[ERROR] /C:/path/DataServlet.java:[3,30] package xxx.java.helpers does not exist

Now this has been asked before and the most rigorous solution appears to be to create a local repo: Can I add jars to maven 2 build classpath without installing them? (NB: I am at maven 3).

I would like to avoid this - so is there any way maven will just stuff this jar to WEB-INF\lib in the war ?

Solutions that use some maven plugin to cp the contents of the WEB-INF\lib in the war are welcome - although I just have this feeling that there should be a solution that takes into account the "special" nature of this folder.

Observations:

  • Alt+F5 removes this line:

    <classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
    

    which corresponds to the "Web App libraries" in the Java Build Path. So not only maven refuses to take into account the WEB-INF\lib - it also breaks the build path of eclipse completely.

Related:

解决方案

Did you add this jar from WEB-INF\lib as a dependency like this:

<dependency>
  <groupId>someGroupId</groupId>
  <artifactId>someArtifactId</artifactId>
  <version>1.0.0</version>
  <scope>system</scope>
  <systemPath>${basedir}/src/main/webapp/WEB-INF/lib/homebrew jar</systemPath>
</dependency>

这篇关于可以通过eclipse(和m2e)的方式来处理WEB-INF \lib吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆