gpt4 book ai didi

java - Google 联系人 - java.lang.NoSuchMethodError : com. google.common.collect.ImmutableSet.of([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;

转载 作者:行者123 更新时间:2023-12-03 21:56:18 25 4
gpt4 key购买 nike

POM.xml :

<?xml version="1.0"?>
<project
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>****</groupId>
<artifactId>****</artifactId>
<version>1.0</version>
</parent>
<groupId>com.web</groupId>
<artifactId>web</artifactId>

<packaging>war</packaging>
<name>web</name>
<url>http://maven.apache.org</url>

<dependencies>
dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
</dependency>

DB Connection Pooling -->
<dependency>
<groupId>commons-dbcp</groupId>
<artifactId>commons-dbcp</artifactId>
<version>1.4</version>
</dependency>

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.connector.version}</version>
</dependency>

<!-- SPRING -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency>

<!-- Hibernate Validator -->
<!-- Form Validation using Annotations -->
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>5.1.0.Final</version>
<exclusions>
<!-- Exclude SLF4j to avoid version conflicts (we have 1.6.2, this drags
in 1.6.1) -->
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- TILES -->
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>${tiles-version}</version>
</dependency>

<!-- Jackson -->
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<version>${jackson.version}</version>
</dependency>

<!-- CGLIB is required to process @Configuration classes -->
<dependency>
<groupId>cglib</groupId>
<artifactId>cglib</artifactId>
<version>2.2.2</version>
</dependency>

<!-- Servlet API and JSTL -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>

<!-- LOGGING -->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>

<!-- Test -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>common</groupId>
<artifactId>my-common</artifactId>
<version>1.0</version>
</dependency>

<dependency>
<groupId>service</groupId>
<artifactId>my-service</artifactId>
<version>1.0</version>
</dependency>

<dependency>
<groupId>dao</groupId>
<artifactId>my-dao</artifactId>
<version>1.0</version>
</dependency>

<dependency>
<groupId>model</groupId>
<artifactId>my-model</artifactId>
<version>1.0</version>
</dependency>


<dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.6.2</version>
</dependency>


<!-- Apache Commons Upload -->
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>${commons-fileupload}</version>
</dependency>

<!-- Apache Commons Upload -->
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>${commons-io}</version>
</dependency>

<dependency>
<groupId>net.tanesha.recaptcha4j</groupId>
<artifactId>recaptcha4j</artifactId>
<version>${recapchta.version}</version>
</dependency>

<dependency>
<groupId>com.google.gdata</groupId>
<artifactId>core</artifactId>
<version>1.47.1</version>
<dependency>

<dependency>
<groupId>org.openengsb.wrapped</groupId>
<artifactId>com.google.gdata-contacts</artifactId>
<version>1.41.5.w1</version>
</dependency>
<dependencies>
</project>

当我尝试执行以下代码时出现异常:

private ContactsService authenticateId(String userid, String password) {

ContactsService contactService = null;
try {
contactService = new ContactsService("exampleCo-exampleApp-1");
contactService.setUserCredentials(userid, password);

} catch (Exception e) {
System.out.println(e);
}
return contactService;

}

异常:

java.lang.NoSuchMethodError: com.google.common.collect.ImmutableSet.of([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;
at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableTypes(AltFormat.java:399)
at com.google.gdata.wireformats.AltFormat$Builder.setAcceptableXmlTypes(AltFormat.java:387)
at com.google.gdata.wireformats.AltFormat.<clinit>(AltFormat.java:49)
at com.google.gdata.client.Service.<clinit>(Service.java:558)

在我的 .m2 文件夹中,我可以看到它正在获取许多版本的 Guava ,因为我可能有其他依赖项,如 gson,我猜它也在使用 Guava 。

尝试为 guava r07 添加外部依赖,但没有成功。

在我的 POC 示例中,相同的代码非常有用,在该 POM 中,仅添加了两个与 gdata 相关的 Maven 依赖项。

最佳答案

我认为您遇到了 this bug report 中描述的问题

It is very dangerous to use google-collect.jar, as if a user ends up with that and guava on her classpath at the same time, very unpredictable and strange errors can result.

在您的 pom 中声明的其他库(可能是 GSON)隐式地将 Guava 添加到您的类路径中。而你只是遇到了这些“不可预测和奇怪的错误”;-)

StackOverflow 上有人有 similar problem .也许你可以像他那样做,即明确声明 rc05 版本的 Guava 以强制 maven 使用这个版本? (参见:this answer)

关于java - Google 联系人 - java.lang.NoSuchMethodError : com. google.common.collect.ImmutableSet.of([Ljava/lang/Object;)Lcom/google/common/collect/ImmutableSet;,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25808115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com