Java 将SpringCloudGateway与oauth2一起使用
我在使用SpringCloudGateway时遇到了一个问题 是否有依赖项直接或递归地调用spring boot starter tomcat 它将无法工作,因为它将启动嵌入式tomcat服务器,而不是SpringCloudGateway使用的netty服务器 我开始通过排除这种依赖性来解决这个问题Java 将SpringCloudGateway与oauth2一起使用,java,spring,spring-oauth2,spring-cloud-gateway,Java,Spring,Spring Oauth2,Spring Cloud Gateway,我在使用SpringCloudGateway时遇到了一个问题 是否有依赖项直接或递归地调用spring boot starter tomcat 它将无法工作,因为它将启动嵌入式tomcat服务器,而不是SpringCloudGateway使用的netty服务器 我开始通过排除这种依赖性来解决这个问题 <exclusions> <exclusion> <groupId>org.springf
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
org.springframework.boot
弹簧启动机tomcat
spring云网关成功运行
但有时我想使用spring-cloud-starter-oauth2来使用@enableouth2sso
我开始使用
<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>
org.springframework.cloud
spring-cloud-starter-oauth2
org.springframework.boot
弹簧启动机tomcat
当时我面临着抛出异常的大问题
原因:java.lang.IllegalStateException:未能内省类org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2Client配置上的带注释的方法
原因:java.lang.NoClassDefFoundError:javax/servlet/Filter
正如您所看到的,SpringCloudGateway使用反应式模型,并且基于netty而不是tomcat。被动更改是一个主要的转变,目前不受Spring Security的支持,但工作正在进行中,您可以在Spring boot 2.1和Spring Security 5中跟踪它,以解决此问题
参见此使用以下依赖项(我从build.gradle复制) 对网关应用程序进行最低限度的编码,如下所示
@springboot应用程序
公共类应用程序{
@豆子
公共转发磁头变压器转发磁头变压器(){
返回新的转发磁头变压器();
}
公共静态void main(字符串[]args){
SpringApplication.run(App.class,args);
}
}
在application.yml中配置
spring:
安全:
oauth2:
客户:
注册:
谷歌:
客户id:XXX
客户机密:YYY
我正在积极构建使用OAuth2和Docker Swarm Discovery的堆栈,这样您就可以看到它将如何工作。您找到解决方案了吗?我也面临着同样的问题我也面临着这个问题,在花了将近两天的时间找不到任何东西之后。。。我只是想知道这个问题是否以某种方式得到了解决,是否有可以参考的参考文件。我也面临着这个问题,在花了将近2天的时间后,什么都找不到。。。我只是想知道这个问题是否以某种方式得到了解决,是否有可以参考的参考文件
dependencies {
implementation 'org.springframework.cloud:spring-cloud-starter-gateway'
implementation 'org.springframework.cloud:spring-cloud-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
}