2013-01-24 40 views
1

我試圖做一個部署包,它捆綁了我的maven模塊的所有依賴關係到eclipse中的另一個maven項目。m2e陰影蝕「項目主神器不存在」

我有這個在我的pom.xml

<modelVersion>4.0.0</modelVersion> 
<groupId>com.my.proj</groupId> 
<artifactId>AAA</artifactId> 
<version>0.0.2-SNAPSHOT</version> 
<name>btc</name> 
<dependencies> 
    <dependency> 
     <groupId>com.another.proj</groupId> 
     <artifactId>BBB</artifactId> 
     <version>1.4-SNAPSHOT</version> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-shade-plugin</artifactId> 
      <version>1.6</version> 
      <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>shade</goal> 
        </goals> 
        <configuration> 
         <transformers> 
          <transformer 
           implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
           <mainClass>com.group.id.Launcher1</mainClass> 
          </transformer> 
         </transformers> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

    </plugins> 
</build> 

我用「M2 Maven構建」在Eclipse中的目標「org.apache.maven.plugins:行家遮陽簾插件:燈罩」和「解決工作區工件」打勾。

它的失敗與

--- maven-shade-plugin:1.6:shade (default-cli) @ AAA --- 
[ERROR] The project main artifact does not exist. This could have the following 
[ERROR] reasons: 
[ERROR] - You have invoked the goal directly from the command line. This is not 
[ERROR] supported. Please add the goal to the default lifecycle via an 
[ERROR] <execution> element in your POM and use "mvn package" to have it run. 
[ERROR] - You have bound the goal to a lifecycle phase before "package". Please 
[ERROR] remove this binding from your POM such that the goal will be run in 
[ERROR] the proper phase. 

我在這一點上跑出的想法。

回答

3

陰影插件試圖在陰影JAR中包含項目的工件。由於它不存在(還),你會得到這個錯誤。您需要先構建/打包項目工件(例如,通過將陰影目標附加到包裝階段)

如果在陰影JAR中沒有任何項目工件,則可以添加一個排除節點刪除項目的工件。

下面是一個例子:

<plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-shade-plugin</artifactId> 
     <version>1.6</version> 
     <executions> 
      <execution> 
       <phase>package</phase> 
       <goals> 
        <goal>shade</goal> 
       </goals> 
       <configuration> 
        <transformers> 
         <transformer 
          implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
          <mainClass>com.group.id.Launcher1</mainClass> 
         </transformer> 
        </transformers> 
        <excludes> 
         <exclude>com.my.proj:AAA</exclude> 
        </excludes> 
       </configuration> 
      </execution> 
     </executions> 
    </plugin> 
9

[錯誤]項目主神器不存在。這可能有以下幾種:

我們最近遇到了這個問題。什麼解決這對我們來說是mvn shade:shade而是使用:

mvn package 

這確實額外的編譯和打包工作運行前的樹蔭插件等主類是可用的類路徑上。