【问题标题】:Maven: build ear: skip compile phase?Maven:构建耳朵:跳过编译阶段?
【发布时间】:2012-05-07 06:46:28
【问题描述】:

这是 POM 的一部分
...

   <groupId>com.soft</groupId>
   <artifactId>config-ear</artifactId>
   <version>1.0-SNAPSHOT</version>
   <packaging>ear</packaging>

   <name>Enterprise Application</name>
   <url>http://maven.apache.org</url>

   <build>
      <plugins>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.0.2</version>
            <configuration>
               <source>1.6</source>
               <target>1.6</target>
            </configuration>
         </plugin>
         <plugin>
            <groupId>org.codehaus.mojo</groupId>      
            <artifactId>jaxws-maven-plugin</artifactId>
            <executions>
               <execution>
                  <goals>
                     <goal>wsgen</goal>
                  </goals>
                  <configuration>
                     <sei>com.soft.WebService</sei>
                     <genWsdl>true</genWsdl>           
                     <keep>true</keep>
                  </configuration>
               </execution>
            </executions>
         </plugin>
         <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-ear-plugin</artifactId>
            <version>2.6</version>
            <configuration>
               <version>1.4</version>
               <defaultLibBundleDir>lib</defaultLibBundleDir>
            </configuration>
         </plugin>
      </plugins>
   </build>  
...  

运行 mvn 全新安装

[clean:clean]
Deleting directory D:\Development\config-ear\target
[ear:generate]
Generating application.xml
[resources:resources]
Using 'UTF-8' encoding to copy filtered resources.
skip non existing resourceDirectory D:\Development\config-ear\src\main\resources
[jaxws:wsgen]
Class not found: "com.soft.WebService"  

这个类存在于 src/main/java/com/soft/WebService.java
编译阶段在哪里??

【问题讨论】:

    标签: java maven maven-2


    【解决方案1】:

    来自Maven Lifecycle Reference:

    默认生命周期绑定 - 包装耳

    generate-resources  ear:generateApplicationXml
    process-resources   resources:resources
    package             ear:ear
    install             install:install
    deploy              deploy:deploy
    

    如您所见,EAR 生命周期不包含编译阶段

    【讨论】:

      【解决方案2】:

      我认为您不应该将 Java 源代码直接放在您的 EAR 项目中。 EAR 项目应该只引入其他工件,例如WAR、EJB 或 JAR 文件与您的类。

      因此,如果您想要在您的 EAR 文件中添加一些自定义类,您将必须创建另一个带有 JAR 打包的项目,然后将其作为您的 EAR 项目的依赖项包含在内。

      请看这个问题的第一个答案,它显示了 EAR 打包的推荐结构:Maven2: Best practice for Enterprise Project (EAR file)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-08-18
        • 2012-11-29
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-01-02
        • 1970-01-01
        相关资源
        最近更新 更多