今天尝试在项目中整合redis实现缓存的功能,结果当整合完启动项目时,报了一下的错误:
2020-11-23 18:06:29.286 INFO 8864 --- [ restartedMain] c.f.c.CertificateCollectorApplication : Starting CertificateCollectorApplication using Java 1.8.0_191 on FXR-DESKTOP-54BJKDF with PID 8864 (E:\文档\idea_project\JPA\certificate_collector\target\classes started by test in E:\文档\idea_project\JPA\certificate_collector)
2020-11-23 18:06:29.290 INFO 8864 --- [ restartedMain] c.f.c.CertificateCollectorApplication : The following profiles are active: dev
2020-11-23 18:06:29.355 INFO 8864 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2020-11-23 18:06:29.355 INFO 8864 --- [ restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2020-11-23 18:06:30.433 INFO 8864 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2020-11-23 18:06:30.434 INFO 8864 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFERRED mode.
2020-11-23 18:06:30.455 INFO 8864 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 11 ms. Found 0 JPA repository interfaces.
2020-11-23 18:06:30.476 INFO 8864 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2020-11-23 18:06:30.477 INFO 8864 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2020-11-23 18:06:30.490 INFO 8864 --- [ restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 4 ms. Found 0 Redis repository interfaces.
2020-11-23 18:06:31.189 INFO 8864 --- [ restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 3010 (http)
2020-11-23 18:06:31.200 INFO 8864 --- [ restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-11-23 18:06:31.200 INFO 8864 --- [ restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.39]
2020-11-23 18:06:31.325 INFO 8864 --- [ restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-11-23 18:06:31.325 INFO 8864 --- [ restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1968 ms
2020-11-23 18:06:31.420 WARN 8864 --- [ restartedMain] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'cacheManager' defined in class path resource [org/springframework/boot/autoconfigure/cache/RedisCacheConfiguration.class]: Unsatisfied dependency expressed through method 'cacheManager' parameter 4; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.data.redis.LettuceConnectionConfiguration': Unsatisfied dependency expressed through constructor parameter 0; nested exception is org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'spring.redis-org.springframework.boot.autoconfigure.data.redis.RedisProperties': Could not bind properties to 'RedisProperties' : prefix=spring.redis, ignoreInvalidFields=false, ignoreUnknownFields=true; nested exception is org.springframework.boot.context.properties.bind.BindException: Failed to bind properties under 'spring.redis.lettuce' to org.springframework.boot.autoconfigure.data.redis.RedisProperties$Lettuce
2020-11-23 18:06:31.423 INFO 8864 --- [ restartedMain] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-11-23 18:06:31.445 INFO 8864 --- [ restartedMain] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-11-23 18:06:31.467 ERROR 8864 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
Description:
Failed to bind properties under 'spring.redis.lettuce' to org.springframework.boot.autoconfigure.data.redis.RedisProperties$Lettuce:
Reason: No converter found capable of converting from type [java.lang.String] to type [org.springframework.boot.autoconfigure.data.redis.RedisProperties$Lettuce]
Action:
Update your application's configuration
Process finished with exit code 0
上网查了半天没有找到解决方法,后来再次仔细查看所报的错误后,发现了这个:
Action:
Update your application's configuration
去查看了自己的yml文件:
发现在redis配置里多写了一个lettuce,将这个删除即可。
回去一查看,果然是有断点打在了方法上,把所有断点静音果然项目启动起来了,现在想想,真的是太粗心了。的某个服务一到这一步就卡住了,找了半天也不知道是什么问题。这次几下,防止以后再犯!到后来到网上一搜,说是。
最开始看到这个错误以为是自己配置有问题,但发现同样环境另一个分支代码没问题正常启动,所以排除环境问题,锁定应该是代码问题。
因为这套项目由于公司技术选型原因要将原来dubbo转换成spring cloud这样的方式,所以在这个过程中进行fegin改造,发现bug是代码@FeignClient(value="sdfsd")服务名上加了/即@FeignClient(value="/sdfsd")这样导致的该问题。清理后正常启动。
Failed to bind properties under 'spring.redis.port' to int:
Property: spring.redis.port
Value: 6379;
Origin: class path resource [application.properties] - 19:20
Reason: failed to convert java.lang.String to int
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-redis&l...
@ConfigurationProperties(prefix = "prop.bind")
public class BindConfig {
private String name;
private Integer age;
private List<String> list;
private Map<String, String> map;...
刚创建的 Spring Boot 2.0 项目,启动后输出:Failed to bind properties under 'spring.datasource.type' to java.lang.Class<javax.sql.DataSource>:
Property: spring.datasource.type
Value: org.apache.tomca...
Caused by: org.springframework.boot.context.properties.ConfigurationPropertiesBindException: Error creating bean with name 'foodProperties': Could not bind properties to 'FoodProperties' : prefix=con...