Eclipse maven jboss项目 - 我需要将什么添加到pom.xml以便maven可以编译?

时间:2014-06-15 18:10:26

标签: eclipse maven jboss m2eclipse eclipse-wtp

我设法在maven中设置我的Jboss WTP项目。右键单击项目>以>运行在服务器上运行(Jboss 7)工作正常。但是,如果我继续删除target目录,然后尝试执行compile目标,则会失败并且缺少依赖项:

[INFO] Scanning for projects...
[INFO] 
[INFO] Using the builder org.apache.maven.lifecycle.internal.builder.\
singlethreaded.SingleThreadedBuilder with a thread count of 1
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building PROJECT 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ PROJECT ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\path\\src\main\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ PROJECT ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 5 source files to C:\path\\target\classes
[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] /C:/path/to/file/Controller.java:[14,21] package javax.servlet does not exist
#..... NOTICE THIS COMES FROM A CUSTOM JAR
[ERROR] /C:/path/to/file/DataServlet.java:[3,30] package gr.uoa.di.java.helpers does not exist
#.....
[ERROR] /C:/path/to/file/DataServlet.java:[26,32] package javax.servlet.annotation does not exist
[ERROR] /C:/path/to/file/DataServlet.java:[28,26] package javax.servlet.http does not exist
#.....
[INFO] 49 errors 
[INFO] -------------------------------------------------------------
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------

如果我清理项目所以目标目录用类填充,那么尝试编译项目就好了:

[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ DataCollectionServlet ---
[INFO] Nothing to compile - all classes are up to date

我有一个问题:

  • 我应该在pom.xml 中添加什么来重现Run on Server eclipse命令的编译环境? 编辑:例如adding

    <dependency>
        <groupId>javax</groupId>
        <artifactId>javaee-api</artifactId>
        <version>7.0</version>
        <scope>provided</scope>
    </dependency>
    
    pmp解决了未找到的&#34; servlet API&#34;问题 - 但它是要走的路?或者我应该添加something like

    <dependency>
        <groupId>org.jboss.as</groupId>
        <artifactId>jboss-as-spec-api</artifactId>
        <version>7.1.1.Final</version>
    </dependency>
    

    (见here)。 NB :添加m2e插件建议的依赖项会导致巨大的pom - 而且我不确定是否需要它(它是一个普通的servlet / jsp项目):

    enter image description here

我在Eclipse Luna Java EE包,maven 3.1(eclipse附带的那个)和使用Jboss 7.1.1.Final

1 个答案:

答案 0 :(得分:1)

我最后只是添加:

<dependency>
    <groupId>org.glassfish.web</groupId>
    <artifactId>javax.servlet.jsp.jstl</artifactId>
    <version>1.2.1</version>
    <scope>provided</scope>
</dependency>

这传递了servlet-api:

enter image description here

仍然不知道添加这是否是添加jstl 1.2.1的正确方法 - 请注意它添加了jstl 1.2 api(编辑:它不是:Standard way of adding JSLT 1.2.1 in a Maven Project?

我的自制jar(Can maven treat WEB-INF\lib the way eclipse (and m2e) does?)仍然存在问题,但现在关闭它。