Я создаю весеннюю настройку облака.У меня есть Eureka Server, Auth Server, Gateway и два микросервиса.Я использую Zuul для Gateway.Ниже приведена конфигурация сервера Eureka: Главный класс
@SpringBootApplication
@EnableEurekaServer
@EnableAdminServer
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
Свойства приложения:
server.port: 8761
spring.application.name: discovery-server
logging.level.org.springframework.cloud.netflix.eureka: TRACE
eureka.instance.hostname: localhost
eureka.client.registerWithEureka: false
eureka.client.fetchRegistry: false
eureka.client.serviceUrl.defaultZone:
http://${eureka.instance.hostname}:${server.port}/eureka/
spring.boot.admin.context-path= /admin
Шлюз: Главный класс:
@SpringBootApplication
@EnableZuulProxy
@EnableOAuth2Sso
public class GatewayApplication {
public static void main(String[] args) {
SpringApplication.run(GatewayApplication.class, args);
}
}
Свойства:
server.port= 8765
spring.application.name= gateway-server
spring.jpa.database-platform= org.hibernate.dialect.MySQL5Dialect
spring.jpa.database= MYSQL
spring.jpa.open-in-view= false
spring.jpa.hibernate.ddl-auto= create
spring.jpa.properties.hibernate.implicit_naming_strategy=
org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
spring.jpa.properties.hibernate.id.new_generator_mappings= false # id
generation defaults to table otherwise
spring.jpa.properties.hibernate.enable_lazy_load_no_trans= true
spring.jpa.properties.hibernate.generate_statistics= false
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.jdbc-url= jdbc:mysql://localhost:3306/cloudDB?
useUnicode=true&createDatabaseIfNotExist=true&useSSL=false
spring.datasource.username= root
spring.datasource.password= root
spring.datasource.dbcp2.max-idle= 10000
logging.level.org.springframework.cloud.netflix.zuul= TRACE
zuul.routes.uaa.path= /uaa/**
zuul.routes.uaa.sensitiveHeaders=""
zuul.routes.uaa.serviceId= auth-server
zuul.routes.account.path= /account/**
zuul.routes.account.sensitiveHeaders= ""
zuul.routes.account.serviceId= account-service
zuul.routes.customer.path= /customer/**
zuul.routes.customer.sensitiveHeaders=
zuul.routes.customer.serviceId= customer
zuul.routes.fsp.path= /fsp/**
zuul.routes.fsp.sensitiveHeaders=
zuul.routes.fsp.serviceId= fsp-marketplace
eureka.client.registerWithEureka= false
eureka.client.serviceUrl.defaultZone= http://localhost:8761/eureka/
security.oauth2.sso.loginPath= /uaa/login
security.oauth2.client.accessTokenUri= http://localhost:8765/uua/oauth/token
security.oauth2.client.userAuthorizationUri= http://localhost:8765/uua/oauth/authorize
security.oauth2.client.clientId= acem
security.oauth2.client.clientSecret= secret
security.oauth2.client.clientAuthenticationScheme= form
security.oauth2.resource.userInfoUri= http://localhost:8765/user
security.oauth2.resource.preferTokenInfo= false
security.sessions= ALWAYS
Micro Service:
@SpringBootApplication
@EnableAutoConfiguration
@EnableDiscoveryClient
public class FspApplication {
public static void main(String[] args) {
SpringApplication.run(FspApplication.class, args);
}
}
Свойства:
server.port= ${PORT:4444}
spring.application.name= fsp-marketplace
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.database= MYSQL
spring.jpa.hibernate.ddl-auto= update
spring.jpa.properties.hibernate.implicit_naming_strategy=
org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.jdbc-url= jdbc:mysql://localhost:3306/cloudDB?
useUnicode=true&createDatabaseIfNotExist=true&useSSL=false
spring.datasource.username= root
spring.datasource.password= root
spring.datasource.dbcp2.max-idle= 10000
logging.level.org.springframework.security= TRACE
security.user.name= root
security.user.password= password
security.oauth2.resource.userInfoUri= http://localhost:8999/user
eureka.client.serviceUrl.defaultZone= http://localhost:8761/eureka/
Если кто-нибудь может помочь мне в этом, заранее спасибо.:) Все приложения работают нормально индивидуально.Но когда я запускаюсь в кластере после обнаружения службы
Eureka Server
зависает через несколько минут.
Я получаю это исключение в клиенте обнаружения:
DiscoveryClient_AUTH-SERVER/192.168.3.180:auth-server:8999 - de-
registration failedCannot execute request on any known server
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
at com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:112) ~[eureka-client-1.9.0.jar:1.9.0]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71) ~[eureka-client-1.9.0.jar:1.9.0]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$2.execute(EurekaHttpClientDecorator.java:74) ~[eureka-client-1.9.0.jar:1.9.0]
at com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77) ~[eureka-client-1.9.0.jar:1.9.0]
at com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.cancel(EurekaHttpClientDecorator.java:71) ~[eureka-client-1.9.0.jar:1.9.0]
at com.netflix.discovery.DiscoveryClient.unregister(DiscoveryClient.java:923) [eureka-client-1.9.0.jar:1.9.0]
at com.netflix.discovery.DiscoveryClient.shutdown(DiscoveryClient.java:901) [eureka-client-1.9.0.jar:1.9.0]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101]
at org.springframework.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:223) [spring-core-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.cloud.context.scope.GenericScope$LockedScopedProxyFactoryBean.invoke(GenericScope.java:483) [spring-cloud-context-2.0.0.RC2.jar:2.0.0.RC2]
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:185) [spring-aop-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212) [spring-aop-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at com.sun.proxy.$Proxy129.shutdown(Unknown Source) [na:na]
at org.springframework.cloud.netflix.eureka.serviceregistry.EurekaRegistration.close(EurekaRegistration.java:207) [spring-cloud-netflix-eureka-client-2.0.0.RC2.jar:2.0.0.RC2]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_101]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_101]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_101]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_101]
at org.springframework.beans.factory.support.DisposableBeanAdapter.invokeCustomDestroyMethod(DisposableBeanAdapter.java:337) [spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:271) [spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:577) [spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:549) [spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:957) [spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:510) [spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:964) [spring-beans-5.0.6.RELEASE.jar:5.0.6.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1041) [spring-context-5.0.6.RELEASE.jar:5.0.6.RELEASE]
Сервер аутентификации:
@SpringBootApplication
@EnableAuthorizationServer
@EnableDiscoveryClient
@EnableResourceServer
public class AuthServerApplication {
public static void main(String[] args) {
SpringApplication.run(AuthServerApplication.class, args);
}
@Bean
@Primary
@ConfigurationProperties(prefix = "spring.datasource")
public DataSource datasource() {
return DataSourceBuilder.create().build();
}
}
Свойства приложения:
server.port= 8999
spring.application.name= auth-server
spring.jpa.database-platform=org.hibernate.dialect.MySQLDialect
spring.jpa.database= MYSQL
spring.jpa.hibernate.ddl-auto= update
spring.jpa.properties.hibernate.implicit_naming_strategy= org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.jdbc-url= jdbc:mysql://localhost:3306/cloudDB1?useUnicode=true&createDatabaseIfNotExist=true&useSSL=false
spring.datasource.username= root
spring.datasource.password= root
spring.datasource.dbcp2.max-idle= 10000
logging.level.org.springframework.security= TRACE
security.basic.enabled= false
security.user.name= root
security.user.password= password
security.oauth2.client.client-id= acem
security.oauth2.client.client-secret= secret
eureka.client.serviceUrl.defaultZone= http://localhost:8761/eureka/