Java 从spring boot将zookeeper连接到@EnableDiscoveryClient时出现问题
如果按如下方式使用spring启动应用程序,我将收到警告消息“多个Java 从spring boot将zookeeper连接到@EnableDiscoveryClient时出现问题,java,spring,spring-boot,apache-zookeeper,Java,Spring,Spring Boot,Apache Zookeeper,如果按如下方式使用spring启动应用程序,我将收到警告消息“多个@EnableDiscoveryClient的实现”********” 运行此tomcat时正在注册服务实例,但同一实例未在JBOSS EAP 6.1中注册 tomcat和JBOSS中的警告消息 Tomcat: Tomcat: More than one implementation of @EnableDiscoveryClient (now relying on @Conditionals to pick one): [or
@EnableDiscoveryClient的实现”
********”
运行此tomcat时正在注册服务实例,但同一实例未在JBOSS EAP 6.1中注册
tomcat和JBOSS中的警告消息
Tomcat:
Tomcat:
More than one implementation of @EnableDiscoveryClient (now relying on @Conditionals to pick one):
[org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryClientConfiguration,
org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration]
JBOSS EAP:
More than one implementation of @EnableDiscoveryClient (now relying on @Conditionals to pick one):
[org.springframework.cloud.netflix.eureka.EurekaDiscoveryClientConfiguration,
org.springframework.cloud.zookeeper.discovery.ZookeeperDiscoveryClientConfiguration]
我们可以注意到发现客户端在两台服务器中的顺序是不同的,不确定,因为它是在tomcar中注册的,而不是在JBOSS中注册的,因为我想使用ZookePerDiscoveryClientConfiguration
@SpringBootApplication
@EnableDiscoveryClient
public class DemoApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
如果我在spring boot上删除@EnableDiscoveryClient
,则实例正在连接zookeeper,但未注册
但我想在JBOSS EAP中运行它,所以无论如何都可以禁用加载EurekaDiscoveryClientConfiguration,而只使用ZookeeperDiscoveryClientConfiguration
@SpringBootApplication
@EnableDiscoveryClient
public class DemoApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
Bootstrap.yml
spring:
cloud:
zookeeper:
connect-string: localhost:2181
loadBalancerType: ROUND_ROBIN
如果不使用,为什么需要在类路径中使用eureka?我正在类路径中添加eureka,但它正在与spring云库一起添加。不知道如何禁用加载eureka Libraries停止将其添加到您的类路径?@Dave,我已经在pom.xml中添加了以下模块,这些模块可能也会加载eureka库。org.springframework.cloud-spring-cloud-starter-org.springframework.cloud-spring-cloud-starter-zookeer-config-org.springframework.cloud-spring-cloud-starter-zookeer发现不确定这是否会起作用特里卡法克这些都不依赖尤里卡。您可以使用“mvn依赖关系:树”找到它的来源。