2012-04-26 31 views
2

這裏是POM
的一部分......Maven:構建耳朵:跳過編譯階段?

<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這班existst /主/ JAVA/COM /柔和/ WebService.java
編譯階段在哪裏?

回答

3

Maven Lifecycle Reference

默認的生命週期綁定 - 包裝耳

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

如您所見,EAR生命週期不包含編譯階段

0

我不認爲你應該在你的EAR項目中直接使用Java源代碼。 EAR項目應該只吸引其他的工件,例如WAR,EJB或JAR文件與你的類。

所以如果你想在你的EAR文件中使用一些自定義的類,你將不得不使用JAR包創建另一個項目,然後把它作爲你的EAR項目的一個依賴項加入。

請看看在這個問題上的第一個答案,它顯示了EAR包裝推薦的結構:Maven2: Best practice for Enterprise Project (EAR file)