连接 "MicroService Gateway" 与 "UAA Server" Jhipster 3.5.0
Connect "MicroService Gateway" with "UAA Server" Jhipster 3.5.0
我创建了一个 UAA 服务器:
? (1/16) Which *type* of application would you like to create? [BETA] JHipster UAA server (for microservice OAuth2 authentication)
然后我创建了一个微服务网关:
? (1/16) Which *type* of application would you like to create? Microservice gateway
...
? (6/16) What is the folder path of your UAA application?. ../elseruaa
- 我在 "docker-compose" 中创建了 docker 个容器,并且创建得很好。
- 我必须在网关上添加一些额外的配置才能与服务器 UAA 一起工作吗?
我在容器网关中得到以下错误跟踪:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.oauth2.provider.token.TokenStore org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration.tokenStore; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tokenStore' defined in class path resource [com/abalia/elser/config/MicroserviceSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.TokenStore]: Factory method 'tokenStore' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtAccessTokenConverter' defined in class path resource [com/abalia/elser/config/MicroserviceSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'jwtAccessTokenConverter' threw exception; nested exception is java.lang.IllegalStateException: No instances available for elseruaa...
非常感谢您的帮助。
Caused by: java.lang.IllegalStateException: No instances available for elseruaa
由 RibbonLoadBalancerClient 报告。
我不是最新的 uaa 支持,但您的网关似乎无法在已注册到您的 JHipster 注册表(Eureka 服务器)的 Eureka 客户端列表中找到名为 elseruaa
的服务).所以要么你忘记启动 elseruaa 要么它用另一个名字注册了。
我遇到了同样的问题。花费数小时后,终于通过在 MicroserviceSecurityConfiguration.java 中添加以下内容修复了错误:
注入org.springframework.cloud.client.discovery.DiscoveryClient
@Inject
private DiscoveryClient discoveryClient;
在MicroserviceSecurityConfiguration.java的任一方法中(我选择getKeyFromAuthorizationServer方法),添加如下内容:
discoveryClient.getServices();
我创建了一个 youtube 截屏视频来展示如何使用 UAA 创建 jhipster (3.5.1) 微服务。我相信您面临的问题与服务的启动顺序有关,或者旧服务未使用 3.5.0+ 代码重新生成。正如您在截屏视频和 github 上的源代码中看到的那样,它按原样工作。
更改您的移动安全配置
@Inject
private DiscoveryClient discoveryClient;
private String getKeyFromAuthorizationServer() {
List<String> services = discoveryClient.getServices();
HttpEntity<Void> request = new HttpEntity<Void>(new HttpHeaders());
String value = (String) this.keyUriRestTemplate
.exchange("http://uaa/oauth/token_key", HttpMethod.GET, request, Map.class).getBody()
.get("value");
return value;
}
所以基本上只有一行:
List<String> services = discoveryClient.getServices();
解决这个问题。
我创建了一个 UAA 服务器:
? (1/16) Which *type* of application would you like to create? [BETA] JHipster UAA server (for microservice OAuth2 authentication)
然后我创建了一个微服务网关:
? (1/16) Which *type* of application would you like to create? Microservice gateway
...
? (6/16) What is the folder path of your UAA application?. ../elseruaa
- 我在 "docker-compose" 中创建了 docker 个容器,并且创建得很好。
- 我必须在网关上添加一些额外的配置才能与服务器 UAA 一起工作吗?
我在容器网关中得到以下错误跟踪:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration.setFilterChainProxySecurityConfigurer(org.springframework.security.config.annotation.ObjectPostProcessor,java.util.List) throws java.lang.Exception; nested exception is org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.security.oauth2.provider.token.TokenStore org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfiguration.tokenStore; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'tokenStore' defined in class path resource [com/abalia/elser/config/MicroserviceSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.TokenStore]: Factory method 'tokenStore' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jwtAccessTokenConverter' defined in class path resource [com/abalia/elser/config/MicroserviceSecurityConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter]: Factory method 'jwtAccessTokenConverter' threw exception; nested exception is java.lang.IllegalStateException: No instances available for elseruaa...
非常感谢您的帮助。
Caused by: java.lang.IllegalStateException: No instances available for elseruaa
由 RibbonLoadBalancerClient 报告。
我不是最新的 uaa 支持,但您的网关似乎无法在已注册到您的 JHipster 注册表(Eureka 服务器)的 Eureka 客户端列表中找到名为 elseruaa
的服务).所以要么你忘记启动 elseruaa 要么它用另一个名字注册了。
我遇到了同样的问题。花费数小时后,终于通过在 MicroserviceSecurityConfiguration.java 中添加以下内容修复了错误:
注入org.springframework.cloud.client.discovery.DiscoveryClient
@Inject
private DiscoveryClient discoveryClient;
在MicroserviceSecurityConfiguration.java的任一方法中(我选择getKeyFromAuthorizationServer方法),添加如下内容:
discoveryClient.getServices();
我创建了一个 youtube 截屏视频来展示如何使用 UAA 创建 jhipster (3.5.1) 微服务。我相信您面临的问题与服务的启动顺序有关,或者旧服务未使用 3.5.0+ 代码重新生成。正如您在截屏视频和 github 上的源代码中看到的那样,它按原样工作。
更改您的移动安全配置
@Inject
private DiscoveryClient discoveryClient;
private String getKeyFromAuthorizationServer() {
List<String> services = discoveryClient.getServices();
HttpEntity<Void> request = new HttpEntity<Void>(new HttpHeaders());
String value = (String) this.keyUriRestTemplate
.exchange("http://uaa/oauth/token_key", HttpMethod.GET, request, Map.class).getBody()
.get("value");
return value;
}
所以基本上只有一行:
List<String> services = discoveryClient.getServices();
解决这个问题。