[英]Getting a guava error while trying to connect to Cassandra in a managed bean
It says i need guava's version to be over 16, but I'm using guava 19. I even did mvn dependency:tree to check if something else is using guava, but there's only that version. 它说我需要番石榴的版本必须超过16,但是我正在使用番石榴19。我什至做了mvndependency:tree来检查是否有其他东西正在使用番石榴,但是只有那个版本。
@Named(value = "glicoseChart")
@Dependent
public class GlicoseChart implements Serializable{
private LineChartModel glicoseModel;
public LongTermPersistence longTerm;
@PostConstruct
public void init() {
createLineModels();
}
public LineChartModel getGlicoseModel() {
return glicoseModel;
}
private void createLineModels() {
glicoseModel = initLinearModel();
}
private LineChartModel initLinearModel()
{
LineChartModel model = new LineChartModel();
longTerm = new LongTermPersistence();
// VVVVVVVVVVVVV
longTerm.connectB();
It gives an error trying to connect. 尝试连接时出现错误。 And the connection code: 以及连接代码:
public void connectB()
{
this.cluster = Cluster.builder()
.addContactPoint("127.0.0.1")
.withPort(9042)
.build();
session = cluster.connect();
}
It gives an error trying to build the cluster. 尝试构建集群时出现错误。 However, if I try to connect in another class, and not in the managed bean, it works just fine. 但是,如果我尝试在另一个类中而不是在托管Bean中进行连接,则可以正常工作。
However, inside the managed bean, i get this error: 但是,在托管bean中,我收到此错误:
Caused by: com.datastax.driver.core.exceptions.DriverInternalError: Detected incompatible version of Guava in the classpath. 原因:com.datastax.driver.core.exceptions.DriverInternalError:在类路径中检测到不兼容的Guava版本。 You need 16.0.1 or higher. 您需要16.0.1或更高版本。 at com.datastax.driver.core.GuavaCompatibility.selectImplementation(GuavaCompatibility.java:138) at com.datastax.driver.core.GuavaCompatibility.(GuavaCompatibility.java:52) 在com.datastax.driver.core.GuavaCompatibility。(GuavaCompatibility.java:52)处com.datastax.driver.core.GuavaCompatibility.selectImplementation(GuavaCompatibility.java:138)
The thing is, i'm using guava-19.0, and it's saying im using 16 below, which is not true, since I can use that piece of code in another class' main. 问题是,我使用的是guava-19.0,它说的是im在下面使用16,这是不正确的,因为我可以在另一类的main中使用那段代码。 I'm using cassandra 3 btw. 我正在使用cassandra 3 btw。
You should use the same guava version as your cassandra-driver-core dependency, to be safe. 为了安全起见,您应该使用与cassandra-driver-core依赖项相同的番石榴版本。 Eg cassandra-driver-core 3.0.0 uses guava 16.0.1 例如cassandra-driver-core 3.0.0使用番石榴16.0.1
See https://mvnrepository.com/artifact/com.datastax.cassandra/cassandra-driver-core 参见https://mvnrepository.com/artifact/com.datastax.cassandra/cassandra-driver-core
The error message only guesses your guava version. 该错误消息仅猜测您的番石榴版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.