2012-12-11 60 views
4

我使用maven-shade-plugin來構建項目,但是,我遇到了一個問題,我無法處理它。有兩個jar幾乎有相同的類,路徑是相同的,aspectjweaver.jar和aspectjrt.jar,當打包jar時,我得到警告「重複的類已經存在....」。我嘗試使用「重新定位」屬性來重新安置課程,但問題是,我如何在兩個罐子中識別課程?接下來是我的Pom.xml的一部分。 org.apache.maven.plugins 行家遮陽簾插件 1.3.1如何避免使用maven的類衝突

  <executions> 
       <execution> 
        <phase>package</phase> 
        <goals> 
         <goal>shade</goal> 
        </goals> 
        <configuration> 

         <filters> 
          <filter> 
           <artifact>org.aspectj:aspectjrt</artifact> 
           <includes> 
            <include>*</include> 
           </includes> 
          </filter> 
         </filters> 
         <relocations> 
          <relocation> 
           <pattern>org.aspectj</pattern> 
           <shadedPattern>hide.org.aspectj</shadedPattern> 
          </relocation> 
         </relocations> 
         <transformers> 
          <transformer 
           implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> 
           <mainClass>cm.data.DatBoostrap</mainClass> 
          </transformer> 
          <transformer 
           implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> 
           <resource>META-INF/spring.handlers</resource> 
          </transformer> 
          <transformer 
           implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer"> 
           <resource>META-INF/spring.schemas</resource> 
          </transformer> 
         </transformers> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 
+0

對不起因錯誤,應該刪除。 –

回答

0

,則應該從文物的一個使用一些這樣的事只是排除類:

<configuration> 
<filters> 
    <filter> 
    <artifact>junit:junit</artifact> 
    <includes> 
    <include>junit/framework/**</include> 
    <include>org/junit/**</include> 
    </includes> 
    <excludes> 
    <exclude>org/junit/experimental/**</exclude> 
    <exclude>org/junit/runners/**</exclude> 
    </excludes> 
    </filter> 
    <filter> 
    <artifact>*:*</artifact> 
    <excludes> 
    <exclude>META-INF/*.SF</exclude> 
    <exclude>META-INF/*.DSA</exclude> 
    <exclude>META-INF/*.RSA</exclude> 
    </excludes> 
    </filter> 
</filters> 
</configuration>