spring boot 项目启动出现错误: “Unable to start embedded Tomcat”
具体看还有"redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required."
详情摘要:
Caused by: org.springframework.boot.context.embedded.EmbeddedServletContainerException: Unable to start embedded Tomcat
...
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'springSessionRepositoryFilter' defined in class path resource [org/springframework/boot/autoconfigure/session/RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.class]: Unsatisfied dependency expressed through method 'springSessionRepositoryFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionRepository' defined in class path resource [org/springframework/boot/autoconfigure/session/RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRepository' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionRedisTemplate' defined in class path resource [org/springframework/boot/autoconfigure/session/RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRedisTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration$RedisConnectionConfiguration.class]: Invocation of init method failed; nested exception is redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
...
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionRepository' defined in class path resource [org/springframework/boot/autoconfigure/session/RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRepository' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionRedisTemplate' defined in class path resource [org/springframework/boot/autoconfigure/session/RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRedisTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration$RedisConnectionConfiguration.class]: Invocation of init method failed; nested exception is redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
...
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'sessionRedisTemplate' defined in class path resource [org/springframework/boot/autoconfigure/session/RedisSessionConfiguration$SpringBootRedisHttpSessionConfiguration.class]: Unsatisfied dependency expressed through method 'sessionRedisTemplate' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration$RedisConnectionConfiguration.class]: Invocation of init method failed; nested exception is redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
...
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'redisConnectionFactory' defined in class path resource [org/springframework/boot/autoconfigure/data/redis/RedisAutoConfiguration$RedisConnectionConfiguration.class]: Invocation of init method failed; nested exception is redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
...
Caused by: redis.clients.jedis.exceptions.JedisDataException: NOAUTH Authentication required.
...
原因:redis,Jedis的密码错误,或者程序里没有取到。
解决方案:
查看配置文件里是否设置密码,密码是否设置正确。
例如配置文件yml中层级关系错误,则可以修改配置文件:
修改前(错误的与cluster一级):
spring:
redis:
cluster:
nodes:
- xx.xxx.xxx.xx:7000
- xx.xxx.xxx.xx:7003
- xx.xxx.xxx.xx:7001
- xx.xxx.xxx.xx:7004
- xx.xxx.xxx.xx:7002
- xx.xxx.xxx.xx:7005
password: test12345
修改后(修改为与redis同级):
spring:
redis:
cluster:
nodes:
- xx.xxx.xxx.xx:7000
- xx.xxx.xxx.xx:7003
- xx.xxx.xxx.xx:7001
- xx.xxx.xxx.xx:7004
- xx.xxx.xxx.xx:7002
- xx.xxx.xxx.xx:7005
password: test12345