Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring IntegrationFlow Http.inboundGateway参数类型不明确_Spring_Spring Boot_Spring Integration - Fatal编程技术网

Spring IntegrationFlow Http.inboundGateway参数类型不明确

Spring IntegrationFlow Http.inboundGateway参数类型不明确,spring,spring-boot,spring-integration,Spring,Spring Boot,Spring Integration,我试图将下面的spring集成示例转换为Java配置版本 我们需要稍微修改一下这个项目的版本才能在生产环境中工作。我的问题是,在启动应用程序时,我一直遇到以下异常 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'httpInboundGateway' defined in org.springframework.platform.proxy.TunnelApplicat

我试图将下面的spring集成示例转换为Java配置版本

我们需要稍微修改一下这个项目的版本才能在生产环境中工作。我的问题是,在启动应用程序时,我一直遇到以下异常

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'httpInboundGateway' defined in org.springframework.platform.proxy.TunnelApplication: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.dsl.IntegrationFlow]: Factory method 'httpInboundGateway' threw exception; nested exception is java.lang.IllegalArgumentException: Found ambiguous parameter type [class [Ljava.lang.String;] for method match: [public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.multipartResolver(org.springframework.web.multipart.MultipartResolver), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.replyMapper(org.springframework.integration.mapping.OutboundMessageMapper), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.autoStartup(boolean), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.mappedResponseHeaders(java.lang.String[]), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.phase(int), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.crossOrigin(org.springframework.integration.dsl.support.Consumer), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.errorChannel(java.lang.String), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.headerMapper(org.springframework.integration.mapping.HeaderMapper), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.requestMapper(org.springframework.integration.mapping.InboundMessageMapper), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.messageConverters(org.springframework.http.converter.HttpMessageConverter[]), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.requestTimeout(long), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.payloadExpression(org.springframework.expression.Expression), public java.lang.Class org.springframework.integration.dsl.core.IntegrationComponentSpec.getObjectType(), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.requestPayloadType(java.lang.Class), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.payloadFunction(org.springframework.integration.dsl.support.Function), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.errorChannel(org.springframework.messaging.MessageChannel)]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) ~[spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:314) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151) [spring-boot-1.5.1.RELEASE.jar:1.5.1.RELEASE]
    at org.springframework.platform.proxy.TestServerApplication.main(TestServerApplication.java:11) [classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.integration.dsl.IntegrationFlow]: Factory method 'httpInboundGateway' threw exception; nested exception is java.lang.IllegalArgumentException: Found ambiguous parameter type [class [Ljava.lang.String;] for method match: [public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.multipartResolver(org.springframework.web.multipart.MultipartResolver), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.replyMapper(org.springframework.integration.mapping.OutboundMessageMapper), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.autoStartup(boolean), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.mappedResponseHeaders(java.lang.String[]), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.phase(int), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.crossOrigin(org.springframework.integration.dsl.support.Consumer), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.errorChannel(java.lang.String), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.headerMapper(org.springframework.integration.mapping.HeaderMapper), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.requestMapper(org.springframework.integration.mapping.InboundMessageMapper), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.messageConverters(org.springframework.http.converter.HttpMessageConverter[]), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.requestTimeout(long), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.payloadExpression(org.springframework.expression.Expression), public java.lang.Class org.springframework.integration.dsl.core.IntegrationComponentSpec.getObjectType(), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.requestPayloadType(java.lang.Class), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.payloadFunction(org.springframework.integration.dsl.support.Function), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.errorChannel(org.springframework.messaging.MessageChannel)]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    ... 18 common frames omitted
Caused by: java.lang.IllegalArgumentException: Found ambiguous parameter type [class [Ljava.lang.String;] for method match: [public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.multipartResolver(org.springframework.web.multipart.MultipartResolver), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.replyMapper(org.springframework.integration.mapping.OutboundMessageMapper), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.autoStartup(boolean), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.mappedResponseHeaders(java.lang.String[]), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.phase(int), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.crossOrigin(org.springframework.integration.dsl.support.Consumer), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.errorChannel(java.lang.String), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.headerMapper(org.springframework.integration.mapping.HeaderMapper), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.requestMapper(org.springframework.integration.mapping.InboundMessageMapper), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.messageConverters(org.springframework.http.converter.HttpMessageConverter[]), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.requestTimeout(long), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.payloadExpression(org.springframework.expression.Expression), public java.lang.Class org.springframework.integration.dsl.core.IntegrationComponentSpec.getObjectType(), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.requestPayloadType(java.lang.Class), public org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec org.springframework.integration.dsl.http.BaseHttpInboundEndpointSpec.payloadFunction(org.springframework.integration.dsl.support.Function), public org.springframework.integration.dsl.core.MessagingGatewaySpec org.springframework.integration.dsl.core.MessagingGatewaySpec.errorChannel(org.springframework.messaging.MessageChannel)]
    at org.springframework.util.Assert.isNull(Assert.java:92) ~[spring-core-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.integration.util.MessagingMethodInvokerHelper.findHandlerMethodsForTarget(MessagingMethodInvokerHelper.java:497) ~[spring-integration-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.integration.util.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:226) ~[spring-integration-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.integration.util.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:149) ~[spring-integration-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.integration.util.MessagingMethodInvokerHelper.<init>(MessagingMethodInvokerHelper.java:144) ~[spring-integration-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.integration.handler.MethodInvokingMessageProcessor.<init>(MethodInvokingMessageProcessor.java:60) ~[spring-integration-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.integration.handler.ServiceActivatingHandler.<init>(ServiceActivatingHandler.java:37) ~[spring-integration-core-4.3.7.RELEASE.jar:4.3.7.RELEASE]
    at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:985) ~[spring-integration-java-dsl-1.2.1.RELEASE.jar:na]
    at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:964) ~[spring-integration-java-dsl-1.2.1.RELEASE.jar:na]
    at org.springframework.integration.dsl.IntegrationFlowDefinition.handle(IntegrationFlowDefinition.java:950) ~[spring-integration-java-dsl-1.2.1.RELEASE.jar:na]
    at org.springframework.platform.proxy.TunnelApplication.httpInboundGateway(TunnelApplication.java:93) ~[classes/:na]
    at org.springframework.platform.proxy.TunnelApplication$$EnhancerBySpringCGLIB$$4e2cc6e6.CGLIB$httpInboundGateway$3(<generated>) ~[classes/:na]
    at org.springframework.platform.proxy.TunnelApplication$$EnhancerBySpringCGLIB$$4e2cc6e6$$FastClassBySpringCGLIB$$e8c73d4b.invoke(<generated>) ~[classes/:na]
    at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.platform.proxy.TunnelApplication$$EnhancerBySpringCGLIB$$4e2cc6e6.httpInboundGateway(<generated>) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_66]
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_66]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[na:1.8.0_66]
    at java.lang.reflect.Method.invoke(Unknown Source) ~[na:1.8.0_66]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    ... 19 common frames omitted
当我运行TunnelaApplication时,我得到了上面的错误。我的maven pom文件修改如下。主要区别在于我使用的是SpringBoot1.5.1,而原始项目使用的是1.1.4.BUILD-SNAPSHOT

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.redi</groupId>
        <artifactId>redi-parent</artifactId>
        <version>5.0.0</version>
    </parent>
    <artifactId>http-amqp-tunnel</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>HTTP AMQP Tunnel</name>

    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-starter-parent</artifactId>
                <version>1.5.1.RELEASE</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-integration</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-amqp</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-http</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-jmx</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <start-class>org.springframework.platform.proxy.TunnelApplication</start-class>
        <java.version>1.8</java.version>
    </properties>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>
我现在导航到时遇到的错误如下:

org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'httpInboundGateway' is expected to be of type 'org.springframework.web.HttpRequestHandler' but was actually of type 'org.springframework.integration.dsl.StandardIntegrationFlow'
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:378) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1087) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.web.context.support.HttpRequestHandlerServlet.init(HttpRequestHandlerServlet.java:57) ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at javax.servlet.GenericServlet.init(GenericServlet.java:158) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1183) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at     

    }
.handleHttp.inboundGateway/tunnel

无法从.handle方法调用入站网关

入站终结点不是使用者

看起来应该是。fromHttp.in


您对amqp入站端点也有同样的问题。

谢谢Gary。这解决了这个问题。该应用程序现在启动,但当我点击时,我得到了以下异常:名为“httpInboundGateway”的Bean应该是“org.springframework.web.HttpRequestHandler”类型,但实际上是“org.springframework.integration.dsl.StandardIntegrationFlow”类型。请将修改后的配置添加到您的问题中。请注意,您必须调用。开始将DSL规范对象解析为实际的集成组件。我发布了修订版。看起来ServletRegistrationBean可能不是正确的方法,他可能正期待着一种特定类型的bean。不过不确定。谢谢,我刚要发布我删除了它,现在至少我得到了一个超时错误。我应该能从这里向前推进。如果不是,我将发布一个不同的问题。谢谢!你是春天之王!您不需要ServiceRegistrationBean,只需删除它即可。关于get,我也是正确的——Http工厂方法不需要它。Dave的项目不使用Spring集成Http网关。
package org.springframework.platform.proxy;

import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.beans.factory.annotation.*;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.*;
import org.springframework.integration.config.EnableIntegration;
import org.springframework.integration.dsl.*;
import org.springframework.integration.dsl.amqp.Amqp;
import org.springframework.integration.dsl.http.Http;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.context.support.HttpRequestHandlerServlet;

@Configuration
@ComponentScan
@EnableAutoConfiguration
@EnableIntegration
public class TunnelApplication 
{
    public static void main(String[] args) 
    {
        SpringApplication.run(TunnelApplication.class, args);
    }

    @Value("${urlExpression}")
    private String urlExpression;

    @Value("${outboundQueue}")
    private String outboundQueue;

    @Value("${inboundQueue}")
    private String inboundQueue;

    @Autowired
    private ConnectionFactory rabbitConnectionFactory;

    @Bean
    public Queue requestQueue() 
    {
        return new Queue(outboundQueue, true, false, true);
    }

    @Bean
    public Queue targetQueue() 
    {
        return new Queue(inboundQueue, true, false, true);
    }

    @Bean
    public ServletRegistrationBean httpInboundGatewayServletRegistration() 
    {
        ServletRegistrationBean bean = new ServletRegistrationBean(httpInboundGatewayServlet(), "/tunnel/*");
        bean.setName("httpInboundGateway");
        return bean;
    }

    @Bean
    public HttpRequestHandlerServlet httpInboundGatewayServlet() 
    {
        return new HttpRequestHandlerServlet();
    }

    @Bean
    public RestTemplate safeRestTemplate()
    {
        return new RestTemplate();
    }

    @Bean
    public Jackson2JsonMessageConverter jsonMessageConverter()
    {
        return new Jackson2JsonMessageConverter();
    }


    @Bean
    public AmqpTemplate amqpTemplate()
    {
        RabbitTemplate result = new RabbitTemplate(rabbitConnectionFactory);
        result.setMessageConverter(jsonMessageConverter());
        return result;
    }

    @Bean
    public IntegrationFlow httpInboundGateway()
    {
        return IntegrationFlows.from(Http.inboundGateway("/tunnel")).channel("outbound")
                .get();
    }

    @Bean
    public IntegrationFlow amqpOutbound(AmqpTemplate amqpTemplate) 
    {
        return IntegrationFlows.from("outbound")
                .handle(
                        Amqp.outboundAdapter(amqpTemplate)
                            .mappedRequestHeaders("http_*")
                            .routingKeyExpression("headers['routingKey']")
                        )
                .get();
    }    

    @Bean
    public IntegrationFlow amqpInboundGateway(ConnectionFactory connectionFactory) 
    {
        return IntegrationFlows.from
                (
                    Amqp.inboundGateway(connectionFactory, inboundQueue)
                        .mappedRequestHeaders("http_*")
                        .messageConverter(jsonMessageConverter())
                )
                .channel("inbound")
                .get();
    }

    @Bean
    public IntegrationFlow httpOutboundGateway()
    {
        return IntegrationFlows.from("inbound").handle(Http.outboundGateway(urlExpression)).get();
    }
org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'httpInboundGateway' is expected to be of type 'org.springframework.web.HttpRequestHandler' but was actually of type 'org.springframework.integration.dsl.StandardIntegrationFlow'
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:378) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1087) ~[spring-context-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at org.springframework.web.context.support.HttpRequestHandlerServlet.init(HttpRequestHandlerServlet.java:57) ~[spring-web-4.3.6.RELEASE.jar:4.3.6.RELEASE]
    at javax.servlet.GenericServlet.init(GenericServlet.java:158) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at org.apache.catalina.core.StandardWrapper.initServlet(StandardWrapper.java:1183) ~[tomcat-embed-core-8.5.11.jar:8.5.11]
    at     

    }