Spring boot cassandra - nested exception is com.datastax.driver.core.exceptions.NoHostAvailableException
1.在Pom.xml添加spring-boot-starter-data-cassandra依赖:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-cassandra</artifactId>
</dependency>
启动spring boot应用,出现错误:
org.springframework.boot.SpringApplication: 815 - Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'session' defined in class path resource [org/springframework/boot/autoconfigure/data/cassandra/CassandraDataAutoConfiguration.class]:
Invocation of init method failed;
nested exception is com.datastax.driver.core.exceptions.NoHostAvailableException:
All host(s) tried for query failed (
tried:
localhost/127.0.0.1:9042 (com.datastax.driver.core.exceptions.TransportException: [localhost/127.0.0.1:9042] Cannot connect),
localhost/0:0:0:0:0:0:0:1:9042 (com.datastax.driver.core.exceptions.TransportException: [localhost/0:0:0:0:0:0:0:1:9042] Cannot connect))
意思是说应用启动失败。是由于在CassandraDataAutoConfiguration类中创建bean时失败了。内部原因是应用启动过程中发现cassandra不可访问,抛出了NoHostAvailableException异常。
默认情况下boot中的自动配置的Cassandra的host是127.0.0.1和0:0:0:0:0:0:0:1,两次尝试都失败了。
=>在本地的C:\Windows\System32\drivers\etc目录中的hosts文件中添加:
192.168.99.100 localhost
将127.0.0.1映射到实际配置的ip,这里使用了在Docker中启用的Cassandra容器。
=>spring boot提供了可以改配置的方式:
在src/main/resources目录下添加application.properties文件,在其中添加:
spring.data.cassandra.contact-points=192.168.99.100
来修改配置信息。
Spring boot cassandra - nested exception is com.datastax.driver.core.exceptions.NoHostAvailableException的更多相关文章
- spring boot rest api exception解决方案
1.控制器级别@ExceptionHandler public class FooController{ //... @ExceptionHandler({ CustomE ...
- spring boot 使用thymeleaf模版 报错:org.thymeleaf.exceptions.TemplateInputException
错误: org.thymeleaf.exceptions.TemplateInputException: Error resolving template "Hello", tem ...
- nested exception is java.io.FileNotFoundException: class path resource [spring/spring-datasource-mog
spring单元測试时发现的问题: org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsin ...
- Spring Boot学习随记
由于早年在管理领域耕耘了一段时间,完美错过了Spring的活跃期, 多少对这个经典的技术带有一种遗憾的心态在里面的, 从下面的我的生涯手绘图中大概可以看出来我的经历. 最近由于新介入到了工业数字化领域 ...
- nested exception is org.xml.sax.SAXParseException; lineNumber: 8; columnNumber: 56; cvc-complex-type.2.4.c通配符的匹配很全面, 但无法找到元素 'dubbo:application' 的声明
严重: Exception sending context initialized event to listener instance of class org.springframework.we ...
- spring boot学习(2) SpringBoot 项目属性配置
第一节:项目内置属性 application.properties配置整个项目的,相当于以前的web.xml: 注意到上一节的访问HelloWorld时,项目路径也没有加:直接是http://loca ...
- Spring Boot (26) RabbitMQ延迟队列
延迟消息就是指当消息被发送以后,并不想让消费者立即拿到消息,而是等待指定时间后,消费者才拿到这个消息进行消费. 延迟队列 订单业务: 在电商/点餐中,都有下单后30分钟内没有付款,就自动取消订单. 短 ...
- Spring Boot (25) RabbitMQ消息队列
MQ全程(Message Queue)又名消息队列,是一种异步通讯的中间件.可以理解为邮局,发送者将消息投递到邮局,然后邮局帮我们发送给具体的接收者,具体发送过程和时间与我们无关,常见的MQ又kafk ...
- Spring Boot 2 实战:常用读取配置的方式
1. 前言 在Spring Boot项目中我们经常需要读取application.yml配置文件的自定义配置,今天就来罗列一下从yaml读取配置文件的一些常用手段和方法. 2. 使用@Value注解 ...
随机推荐
- Nginx使用naxsi防xss、防注入攻击配置
== 对于nginx有相应模块来完成WAF构建,此处使用的是naxsi模块. == 一.安装前提 .必须安装了nginx并可提供基本服务(这个是添加模块儿的前提,自己google吧): .下载naxs ...
- php 使用curl 将文件上传
<?php /** * curl文件上传 * @var struing $r_file 上传文件的路劲和文件名 */ function upload_file($r_f ...
- Problem H. The Fence 通过取余判重,求得某个区间的某些个数为某个数的倍数。
/** 题目:Problem H. The Fence 链接:https://vjudge.net/problem/Gym-101090H 题意:给定一个字符串,只有0或者1: 问:假如两个不同的1之 ...
- jQuery 尺寸 方法
jQuery 提供多个处理尺寸的重要方法: width() height() innerWidth() innerHeight() outerWidth() outerHeight()
- ansible使用
常用ad hoc命令, 如:ansible raleigh -m shell -a 'echo $TERM' ansible webservers -m service -a "name=h ...
- JavaScript 初步认识
首先呢 要成为WEB全栈工程师呢 JavaScript 是必须要会的 高级技术看自身兴趣爱好,但是基础必须掌握 因为有良好的基础学习jQuery会比较轻松. js是一门轻量的脚本语言 我学它主要目的是 ...
- Atitit.软件仪表盘(4)--db数据库子系统-监測
Atitit.软件仪表盘(4)--db数据库子系统-监測 连接数::: 死锁表列表:死锁基础列表(近期几条记录,时间,sql等) 3.对server进行监控.获取CUP.I/O使用情况 4.对数据 ...
- 集成 SOLR 到 TOMCAT 中(傻瓜教程)
按照如下配置,整个 Solr 是绿色版的,可以将 Tomcat 目录复制到任何一个地方运行 1.下载 solr 4.3 版本 2.下载 Tomcat 7 ( 6 也可以),另外可以根据系统下载 32 ...
- redis string底层数据结构sds
redis的string没有采用c语言的字符串数组而采用自定义的数据结构SDS(simple dynamic string)设计 len 为字符串的实际长度 在redis中获取字符串的key长度的时 ...
- [转]JBOSS4.3关于java.lang.OutOfMemoryError: PermGen space解决方法
vi /jboss/bin/run.bat 找到: set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx512m -XX:MaxPermSize=256m 改为: set J ...