将Spring Cloud Gateway与oauth2一起使用
我在使用Spring Cloud Gateway时遇到问题
i face a problem when i using spring cloud gateway
是否有任何依赖关系直接或递归调用spring-boot-starter-tomcat
is if any dependency call spring-boot-starter-tomcat directly or recursively
它将不起作用,因为它将启动嵌入式tomcat服务器而不是Spring Cloud Gateway使用的Netty服务器
it will not work because it will start the embedded tomcat server not the netty server that spring cloud gateway use
我开始通过排除这种依赖来解决此问题
i started to solve this problem by excluding this dependency
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
spring cloud网关成功运行
the spring cloud gateway worked successfully
但是有时候我想使用spring-cloud-starter-oauth2来使用@ EnableOAuth2Sso
but sometimes i want to use spring-cloud-starter-oauth2 to use @EnableOAuth2Sso
我开始使用
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-oauth2</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
那个时候,我面临着抛出异常的大问题
at that time i face the big issue that throw exception saying
原因:java.lang.IllegalStateException:无法自检类org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2ClientConfiguration上的带注释的方法 ......
Caused by: java.lang.IllegalStateException: Failed to introspect annotated methods on class org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2ClientConfiguration ......
原因:java.lang.NoClassDefFoundError:javax/servlet/Filter
Caused by: java.lang.NoClassDefFoundError: javax/servlet/Filter
如您所见,Spring云网关使用反应模型,并且基于netty而不是tomcat.被动更改是一个重大转变,Spring Security目前不支持此更改,但正在进行中,您可以在
As you've seen, the Spring cloud gateway uses the reactive model and is based on netty rather than tomcat. The reactive change is a major shift and currently isn't supported by Spring Security but work is in progress on it and you can track it at https://github.com/spring-cloud/spring-cloud-gateway/issues/179