Spring Data Cassandra无法启动的Spring Boot应用程序

阿比舍克·夏尔马M

我有一个带有Spring Web和Spring Data Cassandra作为依赖项的spring boot应用程序。我在用@SpringBootApplication注释的类中有一个main方法。

    <dependency>
      <artifactId>spring-boot-starter-web</artifactId>
      <groupId>org.springframework.boot</groupId>
    </dependency>
    <dependency>
      <artifactId>spring-boot-starter-data-cassandra</artifactId>
      <groupId>org.springframework.boot</groupId>
    </dependency>
    <!--<dependency>
      <artifactId>java-driver-core</artifactId>
      <exclusions>
        <exclusion>
          <artifactId>*</artifactId>
          <groupId>org.apache.tinkerpop</groupId>
        </exclusion>
      </exclusions>
      <groupId>com.datastax.oss</groupId>
      <version>${cassandra-java-driver.version}</version>
    </dependency>
    <dependency>
      <artifactId>native-protocol</artifactId>
      <groupId>com.datastax.oss</groupId>
      <version>${cassandra-native-protocol.version}</version>
    </dependency>-->
    <dependency>
      <artifactId>lombok</artifactId>
      <groupId>org.projectlombok</groupId>
    </dependency>
  </dependencies>


  <parent>
    <artifactId>spring-boot-starter-parent</artifactId>
    <groupId>org.springframework.boot</groupId>
    <version>2.3.4.RELEASE</version>
  </parent>

  <parent>
    <artifactId>spring-boot-starter-parent</artifactId>
    <groupId>org.springframework.boot</groupId>
    <relativePath/>
    <version>2.3.4.RELEASE</version> <!-- lookup parent from repository -->
  </parent>

  <properties>
    <cassandra-java-driver.version>4.9.0</cassandra-java-driver.version>
    <cassandra-native-protocol.version>1.4.11</cassandra-native-protocol.version>
    <java.version>11</java.version>
    <lombok.version>1.18.16</lombok.version>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.source>11</maven.compiler.source>
    <maven.compiler.target>11</maven.compiler.target>
    <maven.compiler.target>11</maven.compiler.target>
  </properties>

  <properties>
    <java.version>11</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  </properties>

我运行此应用程序并遇到以下错误。

    org.springframework.beans.factory.UnsatisfiedDependencyException: **Error creating bean with name 'org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraSession' defined in class path resource **[org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.datastax.oss.driver.api.core.CqlSession]: Factory method 'cassandraSession' threw exception; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=7ecf2a53): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (io.netty.channel.StacklessClosedChannelException)]
        at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:797) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:227) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1356) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1203) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
        at 
    
    .
    .
    .
    
    
    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cassandraSession' defined in class path resource [org/springframework/boot/autoconfigure/cassandra/CassandraAutoConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.datastax.oss.driver.api.core.CqlSession]: Factory method 'cassandraSession' threw exception; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=7ecf2a53): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (io.netty.channel.StacklessClosedChannelException)]
        at 
    
    .
    .
    .
    
    Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.datastax.oss.driver.api.core.CqlSession]: Factory method 'cassandraSession' threw exception; nested exception is com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=7ecf2a53): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (io.netty.channel.StacklessClosedChannelException)]
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
        at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:650) ~[spring-beans-5.2.9.RELEASE.jar:5.2.9.RELEASE]
        ... 32 common frames omitted
    Caused by: com.datastax.oss.driver.api.core.AllNodesFailedException: Could not reach any contact point, make sure you've provided valid addresses (showing first 1 nodes, use getAllErrors() for more): Node(endPoint=/127.0.0.1:9042, hostId=null, hashCode=7ecf2a53): [com.datastax.oss.driver.api.core.connection.ConnectionInitException: [s0|control|connecting...] Protocol initialization request, step 1 (OPTIONS): failed to send request (io.netty.channel.StacklessClosedCh

annelException)]

我猜这可能是一些与依赖关系有关的问题,但无法弄清楚到底是什么。我尝试了一些在pom.xml中注释过的事情,这些没有用。

阿德里安·萨莫拉(Adrian Zamora)

问题是与cassandra的连接。确保已在cassandra上创建了keyspace-name。之后,在您的项目中,声明一个带有键空间的Bean配置(在我的情况下)mykeyspace您可以访问https://kayaerol84.medium.com/cassandra-cluster-management-with-docker-compose-40265d9de076了解有关设置密钥空间的更多详细信息。

 @Configuration
 public class AppConfig {
    public @Bean CqlSession session() {
       return CqlSession.builder().withKeyspace("mykeyspace").build();
    }
 } 

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

无法使用spring-boot-starter-data-cassandra从Spring Boot应用程序连接到Cassandra

来自分类Dev

Spring Boot 应用程序无法启动?

来自分类Dev

Spring Data Rest Boot应用程序无法以Java配置类启动

来自分类Dev

Spring boot 应用程序启动错误

来自分类Dev

Spring Boot应用程序无法在Tomcat OpenShift中启动

来自分类Dev

Spring Boot应用程序无法在CloudFoundry中启动

来自分类Dev

Spring Boot应用程序无法在CloudFoundry中启动

来自分类Dev

使用简单的 Spring Boot 应用程序出现错误“应用程序无法启动”

来自分类Dev

在Spring Boot应用程序中进行Spring Data Elastic搜索

来自分类Dev

在 Spring Boot 应用程序中包含 Spring Data 会中断自动序列化

来自分类Dev

在Spring应用程序启动之前记录Spring Boot设置

来自分类常见问题

Spring Boot应用程序即服务

来自分类Dev

从Spring Boot应用程序访问SessionFactory

来自分类Dev

黄瓜测试Spring Boot应用程序

来自分类Dev

SSH访问Spring Boot应用程序

来自分类Dev

如何扩展Spring Boot应用程序?

来自分类Dev

Spring Boot应用程序未更改

来自分类Dev

Spring Boot应用程序IntelliJ

来自分类Dev

多个Spring Boot应用程序

来自分类Dev

集群Spring Boot应用程序

来自分类Dev

Spring Boot 应用程序 - Maven 问题

来自分类Dev

Spring Boot应用程序启动时出现IllegalAccessError

来自分类Dev

如何停止启动的Spring Boot应用程序?

来自分类Dev

Spring Boot以编程方式延迟启动Web应用程序

来自分类Dev

Spring Boot应用程序启动时出现IllegalAccessError

来自分类Dev

在 Spring Boot 应用程序中启动 ApplicationContext 时出错

来自分类Dev

Cucumber 测试不启动 Spring Boot 应用程序

来自分类Dev

Apache Camel 路由和 Spring boot:应用程序启动

来自分类Dev

如何在 spring boot 启动期间关闭应用程序

Related 相关文章

  1. 1

    无法使用spring-boot-starter-data-cassandra从Spring Boot应用程序连接到Cassandra

  2. 2

    Spring Boot 应用程序无法启动?

  3. 3

    Spring Data Rest Boot应用程序无法以Java配置类启动

  4. 4

    Spring boot 应用程序启动错误

  5. 5

    Spring Boot应用程序无法在Tomcat OpenShift中启动

  6. 6

    Spring Boot应用程序无法在CloudFoundry中启动

  7. 7

    Spring Boot应用程序无法在CloudFoundry中启动

  8. 8

    使用简单的 Spring Boot 应用程序出现错误“应用程序无法启动”

  9. 9

    在Spring Boot应用程序中进行Spring Data Elastic搜索

  10. 10

    在 Spring Boot 应用程序中包含 Spring Data 会中断自动序列化

  11. 11

    在Spring应用程序启动之前记录Spring Boot设置

  12. 12

    Spring Boot应用程序即服务

  13. 13

    从Spring Boot应用程序访问SessionFactory

  14. 14

    黄瓜测试Spring Boot应用程序

  15. 15

    SSH访问Spring Boot应用程序

  16. 16

    如何扩展Spring Boot应用程序?

  17. 17

    Spring Boot应用程序未更改

  18. 18

    Spring Boot应用程序IntelliJ

  19. 19

    多个Spring Boot应用程序

  20. 20

    集群Spring Boot应用程序

  21. 21

    Spring Boot 应用程序 - Maven 问题

  22. 22

    Spring Boot应用程序启动时出现IllegalAccessError

  23. 23

    如何停止启动的Spring Boot应用程序?

  24. 24

    Spring Boot以编程方式延迟启动Web应用程序

  25. 25

    Spring Boot应用程序启动时出现IllegalAccessError

  26. 26

    在 Spring Boot 应用程序中启动 ApplicationContext 时出错

  27. 27

    Cucumber 测试不启动 Spring Boot 应用程序

  28. 28

    Apache Camel 路由和 Spring boot:应用程序启动

  29. 29

    如何在 spring boot 启动期间关闭应用程序

热门标签

归档