小编ash*_*evo的帖子

使用带有oauth2的spring cloud gateway

我使用Spring云网关时遇到问题

如果任何依赖项直接或递归调用spring-boot-starter-tomcat

它将无法工作,因为它将启动嵌入式tomcat服务器而不是Spring云网关使用的netty服务器

我开始通过排除这种依赖性来解决这个问题

        <exclusions>
            <exclusion>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-tomcat</artifactId>
            </exclusion>
        </exclusions>
Run Code Online (Sandbox Code Playgroud)

春云网关成功运作

但有时我想使用spring-cloud-starter-oauth2来使用@ 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>
Run Code Online (Sandbox Code Playgroud)

那时我面临着抛出异常的大问题

引起:java.lang.IllegalStateException:无法在类org.springframework.security.oauth2.config.annotation.web.configuration.OAuth2ClientConfiguration上内省带注释的方法......

引起:java.lang.NoClassDefFoundError:javax/servlet/Filter

java spring spring-oauth2 spring-cloud-gateway

10
推荐指数
1
解决办法
4217
查看次数

如何处理角度为5的弹簧启动2发出的json流

Spring Boot 2 WebFlux在新版本中生成Json流

例如

@GetMapping(value = "stream", produces = APPLICATION_STREAM_JSON_VALUE)
public Flux<Data> stream() {
    return Flux.interval(Duration.ofSeconds(1)).map(Data::new);
}
Run Code Online (Sandbox Code Playgroud)

将每隔一秒产生一次新的数据

{"value":"1"}
{"value":"2"}
{"value":"3"}
{"value":"4"}
{"value":"5"}
{"value":"6"}
Run Code Online (Sandbox Code Playgroud)

我已经尝试过angular 5 httpclient

findAll(): Observable<Data> {
   return this._http.get<Data>(this.url);
}
Run Code Online (Sandbox Code Playgroud)

但它不适合我,因为我想被反应它不会发送结果,因为它缓存结果,直到连接colsed

我想问一下在角度5中处理这个Json的最佳方法是什么

spring-boot jsonstream angular

6
推荐指数
2
解决办法
1594
查看次数

使用 oauth2-client 作为隐式授权类型时解决 [authorization_request_not_found]

我收到 OAuth2AuthorizationException:[authorization_request_not_found]

当尝试将授权授予类型从授权代码替换为隐式时

 spring:
    security:
      oauth2:
        client:
          registration:
            mobile:
              provider: auth
              client-id: revo
              authorization-grant-type: implicit
              redirect-uri: "{baseUrl}/login/oauth2/code/{registrationId}"
              scope: read
Run Code Online (Sandbox Code Playgroud)

结果将我重定向到 /login/oauth2/code/mobile#access_token={++++}&token_type=bearer&state={++++}&expires_in={++++}

但它是 Whitelabel 错误页面 在此输入图像描述 我可以解决这个 Whitelabel 错误页面吗

spring spring-security spring-oauth2

6
推荐指数
1
解决办法
6592
查看次数

线程中的 spring 安全当前用户

嗨,我在线程范围内使用 Spring Security 时遇到了一些问题

System.out.println(((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId());
new Thread(() -> System.out.println(((User) SecurityContextHolder.getContext().getAuthentication().getPrincipal()).getId())).start();
Run Code Online (Sandbox Code Playgroud)

这两行应该给我当前的用户 ID

第一行按预期工作

第二行给我 NullPointerException 因为没有当前用户它是空值

我发现了这个问题,因为我想将许多行保存到歌曲表中,并且它包含 @CreatedBy 用户,这将要求线程中的当前用户并且会失败,因为这将为当前用户提供空值

spring multithreading spring-security

3
推荐指数
2
解决办法
4875
查看次数

更改spring boot 2.0 context-path

我想更改spring boot 2的上下文路径,例如我想在http:// localhost:8080/test /上提供服务

我的意思是它不适合我使用spring-boot-starter-webflux:2.0.0.RELEASE

它只与spring-boot-starter-web :: 2.0.0.RELEASE一起使用

我试过了

server.servlet.context-path=/test
Run Code Online (Sandbox Code Playgroud)

但是我没有发生任何事情仍然在url http:// localhost:8080 /

spring spring-boot spring-webflux

2
推荐指数
3
解决办法
8290
查看次数

我无法在AWS Fargate中执行超过5个任务

我在使用AWS Fargate时遇到问题

它不能运行超过5个任务,说明

“服务反馈无法放置任务。原因:您可以同时运行的任务数量已达到极限。在此处输入图片说明

amazon-web-services amazon-ecs aws-fargate

2
推荐指数
3
解决办法
1618
查看次数