org.springframework.cloud.gateway.config.GatewayAutoConfiguration中的websocketRoutingFilter方法的参数0需要一个类型为bean的bean

时间:2018-12-21 14:36:39

标签: spring microservices spring-cloud netflix-eureka

我正在通过引用https://piotrminkowski.wordpress.com/2018/04/26/quick-guide-to-microservices-with-spring-boot-2-0-eureka-and-spring-cloud/来开发代码。在此示例中,我将使用Spring Boot V 2.1.1.RELEASE和spring-cloud-dependencies作为Finchley.RELEASE

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>Finchley.RELEASE</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

启动gateway-service时出现以下错误:

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-12-21 19:59:47 ERROR [gateway-service,,,] 

***************************
APPLICATION FAILED TO START
***************************

Description:

Parameter 0 of method websocketRoutingFilter in org.springframework.cloud.gateway.config.GatewayAutoConfiguration required a bean of type 'org.springframework.web.reactive.socket.client.WebSocketClient' that could not be found.

The following candidates were found but could not be injected:
    - Bean method 'reactorNettyWebSocketClient' in 'GatewayAutoConfiguration.NettyConfiguration' not loaded because @ConditionalOnClass did not find required class 'reactor.ipc.netty.http.client.HttpClient'


Action:

Consider revisiting the entries above or defining a bean of type 'org.springframework.web.reactive.socket.client.WebSocketClient' in your configuration.

enter image description here

在启动proxy-service时也出现错误。你能帮我吗?

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-12-21 20:02:19 ERROR [proxy-service,,,] 

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'proxyRequestHelper', defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulProxyAutoConfiguration$NoActuatorConfiguration.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/cloud/netflix/zuul/ZuulProxyAutoConfiguration$EndpointConfiguration.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

GatewayApplication.java

@SpringBootApplication
@EnableDiscoveryClient
public class GatewayApplication {
    public static void main(String[] args) {
        SpringApplication.run(GatewayApplication.class, args);
    }
}

bootstrap.yml

spring:
  application:
    name: gateway-service
  cloud:
    config:
      uri: http://localhost:8088

ProxyApplication.java

@SpringBootApplication
@EnableZuulProxy
@EnableSwagger2
public class ProxyApplication {
    public static void main(String[] args) {
        SpringApplication.run(ProxyApplication.class, args);
    }
}

ProxyApi.java

@Configuration
public class ProxyApi {

    @Autowired
    ZuulProperties properties;

    @Primary
    @Bean
    public SwaggerResourcesProvider swaggerResourcesProvider() {
        return () -> {
            List<SwaggerResource> resources = new ArrayList<>();
            properties.getRoutes().values().stream()
                    .forEach(route -> resources.add(createResource(route.getServiceId(), route.getId(), "2.0")));
            return resources;
        };
    }

    private SwaggerResource createResource(String name, String location, String version) {
        SwaggerResource swaggerResource = new SwaggerResource();
        swaggerResource.setName(name);
        swaggerResource.setLocation("/" + location + "/v2/api-docs");
        swaggerResource.setSwaggerVersion(version);
        return swaggerResource;
    }
}

我见过https://github.com/spring-cloud/spring-cloud-gateway/issues/319,但是我仍然想使用Spring Boot V 2.1.1.RELEASE

0 个答案:

没有答案
相关问题