17

Apache からの 2 つの Maven アーティファクトには、4 つの重複するクラスがあります:commons-beanutils:commons-beanutils:1.8.3およびcommons-collections:commons-collections:3.2.1:

org.apache.commons.collections.ArrayStack
org.apache.commons.collections.Buffer
org.apache.commons.collections.BufferUnderflowException
org.apache.commons.collections.FastHashMap

この重複を避けるために、それらの1つを他のアーティファクトに置き換えることは可能ですか? 私はグーグルを試みましたが、解決策が見つかりませんでした。むしろ悩ましい問題。

4

4 に答える 4

17

この場合、問題は Maven または除外 (通常はこれが問題です) ではありませんが、間違ったバージョンの beanutils を使用している可能性があります。

beanutils jar には、Bean コレクションが含まれているバージョンと含まれていないバージョンがあります。Bean コレクションを使用する beanutils の Maven 依存関係には、commons コレクションが含まれます。コモンズ コレクションを自分で使用している場合は、コア バージョンを使用し、maven 依存関係にコモンズ コレクションを含めます。

ここで少し説明します: http://commons.apache.org/beanutils/

そのページには次のように書かれています。

commons-beanutils.jar - contains everything
commons-beanutils-core.jar - excludes Bean Collections classes
commons-beanutils-bean-collections.jar - only Bean Collections classes

The main commons-beanutils.jar has an optional dependency on Commons Collections
于 2013-01-18T16:23:20.510 に答える
1

この記事のリンクを見てください。除外タグを使用するように指示されています

アップデート

これを見てlink2

<project>
  ...
  <build>
    <plugins>
      <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.0</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <artifactSet>
                <excludes>
                  <exclude>classworlds:classworlds</exclude>
                  <exclude>junit:junit</exclude>
                  <exclude>jmock:*</exclude>
                  <exclude>*:xml-apis</exclude>
                  <exclude>org.apache.maven:lib:tests</exclude>
                  <exclude>log4j:log4j:jar:</exclude>
                </excludes>
              </artifactSet>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  ...
</project>
于 2013-01-18T16:08:10.577 に答える
-1

beanutils JAR からコレクション パッケージを除外すると、うまくいきました :)

于 2013-05-15T21:42:48.927 に答える