[英]Issues with Spring cloud consul config while starting a Groovy app through Spring cloud cli
I am Exploring Consul for discovery and config server. 我正在探索用于发现和配置服务器的领事。 I have added the required dependencies and yml file is set up.
我已经添加了必需的依赖项,并建立了yml文件。 When i try to start the server using spring cloud cli (Spring run .) I am getting the below error which i am unable to resolve.
当我尝试使用spring cloud cli(Spring run。)启动服务器时,出现以下错误,但我无法解决。 Any help is appreciated.
任何帮助表示赞赏。
Error : "A component required a bean named 'configServerRetryInterceptor' that could >not be found."
错误:“一个组件需要一个名为'configServerRetryInterceptor'的bean,该bean>>找不到。”
I tried to define this bean but when i start the app through spring cloud cli it is not recognizing it. 我试图定义这个bean,但是当我通过spring cloud cli启动应用程序时,它无法识别它。
Please see the code below
请看下面的代码
App.groovy
@Grab("spring-cloud-starter-consul-config")
@Grab("spring-cloud-starter-consul-discovery")
@EnableDiscoveryClient
@EnableCircuitBreaker
@RestController
@Log
class Application{
@Autowired
Greeter greeter
int counter = 0
@RequestMapping(value = "/counter", produces = "application/json")
String produce() {
counter++
log.info("Produced a value: ${counter}")
"{\"value\": ${counter}}"
}
@RequestMapping("/")
String home() {
"${greeter.greeting} World!"
}
@RequestMapping(value = '/questions/{questionId}')
@HystrixCommand(fallbackMethod = "defaultQuestion")
def question(@PathVariable String questionId) {
if(Math.random() < 0.5) {
throw new RuntimeException('random');
}
[questionId: questionId]
}
def defaultQuestion(String questionId) {
[questionId: 'defaultQuestion']
}
}
@Component
@RefreshScope
class Greeter {
@Value('${greeting}')
String greeting
}
bootstrap.yml
consul:
host: localhost
port: 8500
config:
enabled: true
prefix: config
defaultContext: master
profileSeparator: '::'
format: FILES
discovery:
instanceId: ${spring.application.name}:${spring.application.instance_id:${random.value}}
health-check-url: http://127.0.0.1:${server.port}/health
This issue was due to unwanted dependencies being pulled. 此问题是由于拉扯了不需要的依赖项造成的。 Explicitly disabling spring cloud config and spring cloud discovery fixed it.
明确禁用Spring Cloud config,Spring Cloud发现对其进行了修复。
spring:
cloud:
config:
enabled: false
discovery:
enabled: false
serviceId: CONFIG
eureka:
client:
register-with-eureka: false
fetch-registry: false
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.