在领事上未找到spring boot webflux部署

31moq8wy  于 2021-10-10  发布在  Java
关注(0)|答案(0)|浏览(248)

我开发了SpringWebFlux项目。它成功地工作了。我试图让我的webflux项目在Windows10上的Consor服务器上被检测到 spring-boot-starter-actuator 依赖性和 spring-cloud-starter-consul-discovery 依赖于pom.xml。

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>

我在spring boot application.properties上设置了一些变量,如下所示,

spring.application.name=blog-service
server.port = 8080
spring.cloud.consul.host=localhost
spring.cloud.consul.port=8500

并在应用程序代码上添加相关注解,

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;

@SpringBootApplication
@EnableDiscoveryClient
public class SpringBlogWebFluxApplication {

    public static void main(String[] args) {
        SpringApplication.run(SpringBlogWebFluxApplication.class, args);
    }
}

在Concur服务器上检测到webflux项目,但运行状况检查至关重要。

agent: Check is now critical: check=service:blog-service-8080

其他具有相同配置的webflux项目在Concur服务器上的运行状况检查正常。区别在于包含错误的项目具有如下安全配置,

@Configuration
@EnableWebFluxSecurity 
public class BlogWebFluxSecurityConfig {

    @Bean 
    public MapReactiveUserDetailsService userDetailsService() {

        UserDetails userWebFlux = User.withUsername("joseph").password(passwordEncoder().encode("password")).roles("USER").build();
        return new MapReactiveUserDetailsService(userWebFlux);
    }

    @Bean 
    public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
        http
        .csrf().disable()
            .authorizeExchange()
            .pathMatchers("/route/user/all", "/route/post/all").permitAll()
            .pathMatchers(HttpMethod.GET, "/route/user/id/**", "/route/user/username/**", "/route/user/email/**").hasRole("USER")
            .pathMatchers(HttpMethod.POST, "/route/user/login", "/route/user/create", "/route/post/create").hasRole("USER")
            .anyExchange().authenticated()
        .and()
        .httpBasic();

        return http.build();
    } 

    @Bean 
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }
}

是否有webflux项目的另一个配置,其中包含要在Concur服务器上检测到的安全性?我附上控制台日志
向领事注册服务:newservice{id='blog-service-8080',name='blog-service',tags=[],address='desktop-jp6o4ev',meta={secure=false},port=8080,enabletagoverride=null,check=check{script='null',dockercontainerid='null',shell='null',interval='10s',ttl='null',http='10http://desktop-jp6o4ev:8080/actuator/health,方法为空,header={},tcp='null',timeout='null',deregistercriticalserviceafter='null',tlsskipverify=null,status='null',grpc='null',grpcusetls=null},checks=null}

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题