簡體   English   中英

嘗試在托管bean中連接到Cassandra時出現番石榴錯誤

[英]Getting a guava error while trying to connect to Cassandra in a managed bean

它說我需要番石榴的版本必須超過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();

嘗試連接時出現錯誤。 以及連接代碼:

 public void connectB()
 {
   this.cluster = Cluster.builder()
           .addContactPoint("127.0.0.1")
           .withPort(9042)
           .build();
   session = cluster.connect();
}

嘗試構建集群時出現錯誤。 但是,如果我嘗試在另一個類中而不是在托管Bean中進行連接,則可以正常工作。

但是,在托管bean中,我收到此錯誤:

原因:com.datastax.driver.core.exceptions.DriverInternalError:在類路徑中檢測到不兼容的Guava版本。 您需要16.0.1或更高版本。 在com.datastax.driver.core.GuavaCompatibility。(GuavaCompatibility.java:52)處com.datastax.driver.core.GuavaCompatibility.selectImplementation(GuavaCompatibility.java:138)

問題是,我使用的是guava-19.0,它說的是im在下面使用16,這是不正確的,因為我可以在另一類的main中使用那段代碼。 我正在使用cassandra 3 btw。

為了安全起見,您應該使用與cassandra-driver-core依賴項相同的番石榴版本。 例如cassandra-driver-core 3.0.0使用番石榴16.0.1

參見https://mvnrepository.com/artifact/com.datastax.cassandra/cassandra-driver-core

該錯誤消息僅猜測您的番石榴版本。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM