无法解决依赖版本冲突(NoSuchMethodError's)

时间:2014-06-25 09:22:28

标签: java maven

我有一个问题(NoSuchMethodError)使用commons-codec lib有我的pom:`http://maven.apache.org/xsd/maven-4.0.0.xsd">     4.0.0

<groupId>com.playtika</groupId>
<artifactId>InfraSessionsBuild</artifactId>
<version>1.0</version>
<packaging>jar</packaging>

<name>InfraSessionsBuild</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
    <dependency>
        <groupId>InfraSession</groupId>
        <artifactId>infra_session</artifactId>
        <version>1.0.13</version>
        <exclusions>
            <exclusion>
                <groupId>com.playtika</groupId>
                <artifactId>playtika-common</artifactId>
            </exclusion>
            <exclusion>
                <groupId>org.slf4j</groupId>
                <artifactId>slf4j-log4j12</artifactId>
            </exclusion>
            <exclusion>
                <artifactId>ConfigurationManager</artifactId>
                <groupId>
                    com.playtika.services.configuration
                </groupId>
            </exclusion>
            <exclusion>
                <artifactId>slf4j-api</artifactId>
                <groupId>org.slf4j</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>com.playtika</groupId>
        <artifactId>game-event</artifactId>
        <version>1.2</version>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
</dependencies>

<distributionManagement>
    <repository>
        <id>artifactory</id>
        <name>artifactory-releases</name>
        <url>http://artifactory.corp/artifactory/libs-release-local</url>
    </repository>

    <snapshotRepository>
        <id>artifactory-snapshot</id>
        <name>artifactory-snapshot</name>
        <url>http://artifactory.corp/artifactory/libs-snapshot-local</url>
    </snapshotRepository>
</distributionManagement>

<repositories>
    <repository>
        <id>spy</id>
        <name>Spy Repository</name>
        <layout>default</layout>
        <url>http://files.couchbase.com/maven2/</url>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>

    <repository>
        <id>maven2-repository.java.net</id>
        <name>Java.net Repository for Maven</name>
        <url>http://download.java.net/maven/2/</url>
        <layout>default</layout>
    </repository>

    <repository>
        <id>artifactory</id>
        <name>artifactory-releases</name>
        <url>http://artifactory.corp/artifactory/libs-release-local</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>

    <repository>
        <id>artifactory-snapshot</id>
        <name>artifactory-snapshot</name>
        <url>http://artifactory.corp/artifactory/libs-snapshot-local</url>
        <releases>
            <enabled>false</enabled>
        </releases>
        <snapshots>
            <updatePolicy>always</updatePolicy>
            <enabled>true</enabled>
        </snapshots>
    </repository>

    <repository>
        <id>com.cloudera.repository.releases</id>
        <url>https://repository.cloudera.com/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>com.cloudera.repository.thirdparty</id>
        <url>https://repository.cloudera.com/content/repositories/third-party/

        </url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
    <repository>
        <id>resin-hessian</id>
        <name>Hessian</name>
        <url>http://caucho.com/m2</url>
    </repository>
</repositories>

<build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.6</source>
                <target>1.6</target>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-assembly-plugin</artifactId>
            <configuration>
                <finalName>InfraSessionAPI</finalName>
                <appendAssemblyId>false</appendAssemblyId>
                <descriptorRefs>
                    <descriptorRef>jar-with-dependencies</descriptorRef>
                </descriptorRefs>
                <archive>
                    <manifest>
                        <mainClass>com.playtika.InfraSessionAPI</mainClass>
                    </manifest>
                </archive>
            </configuration>
            <executions>
                <execution>
                    <id>make-assembly</id> <!-- this is used for inheritance merges -->
                    <phase>package</phase> <!-- bind to the packaging phase -->
                    <goals>
                        <goal>single</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    </plugins>
</build>

` 在这里你可以看到依赖冲突 enter image description here

我使用了排除和依赖管理,但结果是相同的

12:11:02,487 ERROR [SoapUI] An error occured [TestCase [Copy of Register] failed without assertions
], see error log for details
java.lang.NoSuchMethodError: org.apache.commons.codec.binary.Base64.encodeBase64String([B)Ljava/lang/String;
    at com.couchbase.client.http.HttpUtil.buildAuthHeader(HttpUtil.java:55)

有人可以告诉我更好的方法来解决这个问题吗?

1 个答案:

答案 0 :(得分:1)

commons-codec依赖项添加到infra_session项目,并使用更高版本(1.5)解析