我注意到许多人问了同样的问题,但我尝试了他们的方法,但我的问题仍然存在。
我用弹簧靴+尤里卡+祖尔,
spring.cloud.version: 2.0.2
下面是尤里卡服务器:
@SpringBootApplication
@EnableEurekaServer
@Slf4j
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
log.info("-- EurekaServerApplication started --");
}
}以及用于eureka服务器的application.yml:
server:
port: 8888
eureka:
client:
registerWithEureka: false
fetchRegistry: false
healthcheck:
enabled: true
service-url:
defaultZone: http://localhost:8888/eureka下面是Zuul服务器:
@SpringBootApplication
@EnableZuulProxy
@EnableEurekaClient
@Slf4j
public class ZuulServerApplication{
public static void main(String[] args) {
SpringApplication.run(ZuulServerApplication.class, args);
log.info("-- ZuulServerApplication started --");
}
}以及给Zuul的application.yml
server:
port: 7777
eureka:
instance:
appname: zuul-server
client:
serviceUrl:
defaultZone: http://localhost:8888/eureka
zuul:
ignoredServices: '*'
routes:
file-management:
path: /file-management/**
serviceId: file-management和一个微服务文件管理:
@SpringBootApplication
@EnableEurekaClient
@EnableSwagger2
@Slf4j
public class FileManagementApplication {
public static void main(String[] args) {
SpringApplication.run(FileManagementApplication.class, args);
log.info("-- FileManagement started --");
}
}application.yml
... some other configs
server:
port: 8081
eureka:
instance:
appname: file-management
client:
serviceUrl:
defaultZone: http://localhost:8888/eureka我有这个问题有几天,任何帮助都会非常感谢!
发布于 2018-11-08 13:47:44
做完调查之后,我解决了我的问题。我把我的解决方案放在这里,希望这能帮助人们解决同样的问题。
我是怎么解决的
application.yml添加了:spring:
application:
name: file-managementzuul application.yml中添加了以下内容:eureka:
client:
fetchRegistry: true那就成功了。
原因是很多图图和例子都是基于一些旧版本的,所以我想在新版本中,他们做了一些调整。
因此,对于像我这样遇到同样问题的人,请确保你阅读的文档或示例与您使用的版本相匹配。希望这个答案能对某人有所帮助。
发布于 2018-11-06 16:11:35
我在这个配置上没有任何问题:
server:
port: 8881
eureka:
client:
eureka-connection-idle-timeout-seconds: 60
serviceUrl:
defaultZone: http://localhost:8882/eureka/
healthcheck:
enabled: true你可以检查我的回购这里。
另外,如果没有正确的格式,您是否可以尝试注释名称:文件管理和对齐defaultZone.Sometimes yml属性,而不是加载。
https://stackoverflow.com/questions/53171039
复制相似问题