1、Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'productServiceFallback' method
public java.lang.String com.yinjie.mall.service.hystrix.ProductServiceFallback.getUserInfo(java.lang.String)
to {GET /product/product/query/user/info}: There is already 'productServiceImpl' bean method
public java.lang.String com.yinjie.mall.service.ProductServiceImpl.getUserInfo(java.lang.String) throws java.lang.Exception mapped.在整合springcloud的hystrix时,加入了服务降级fallback类ProductServiceFallback时,一直报上面的错,即相应的mapping已经注册过了。
问题出现的原因:@RequestMapping不要出现在@FeignClient修饰的接口上,而应该只出现在method上
出错及代码示例截图
2、22:01:54.305 [restartedMain] ERROR org.springframework.boot.SpringApplication - Application run failed
java.lang.NoSuchMethodError: org.springframework.boot.builder.SpringApplicationBuilder.<init>([Ljava/lang/Object;)V
at org.springframework.cloud.bootstrap.BootstrapApplicationListener.bootstrapServiceContext(BootstrapApplicationListener.java:157)这个问题是由于springboot的版本和springcloud的版本不匹配导致的
我的springboot是2.1.7,但是springcloud使用的是Dalston导致了这个问题,将springcloud的版本改成Finchley版本后解决了这个问题
3、在配置springcloudconfig时,config-server一直访问不到最新的码云仓库中的配置,无论怎么修改都访问不到。
原因:search_paths配置有误,切记以后配置时,不要将仓库名一起配置进来,只需要将仓库名下的目录名配置进来即可,下面举例
spring.cloud.config.enabled=true spring.cloud.config.server.git.uri=https://gitee.com/yj917/config.git spring.cloud.config.server.git.username=账号 spring.cloud.config.server.git.password=密码 #假如你的仓库名叫config-info,配置文件的目录是mall-service-config,记得下面的search_paths一定不能加仓库名,否则是获取不到最新的配置的 spring.cloud.config.server.git.search-paths=mall-service-config
4、