gpt4 book ai didi

java - 子上下文中的 Spring Integration http 端点不起作用

转载 作者:行者123 更新时间:2023-12-01 12:49:54 25 4
gpt4 key购买 nike

当我在根上下文中配置 Http 入站 channel 适配器时,它可以工作:

    <int-http:inbound-channel-adapter id="httpInbount" path="test" channel="ch.http.in" />

<int:channel id="ch.http.in" />

<int:service-activator input-channel="ch.http.in" output-channel="ch.aggr.obj" ref="httpToObjTransformer" method="transform"></int:service-activator>
<bean id="httpToObjTransformer" class="com.nevexis.dcard.integration.transformer.HttpToObjTransformer" />

<int:channel id="ch.aggr.obj">
<int:queue />
</int:channel>

但是当我从子上下文加载它时,它没有注册。

 <int:channel id="ch.aggr.obj">
<int:queue />
</int:channel>

位于根上下文中,我加载

    <?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-http="http://www.springframework.org/schema/integration/http"
xsi:schemaLocation="http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

<int-http:inbound-channel-adapter id="httpInbount" path="transaction" channel="ch.http.in" />

<int:channel id="ch.http.in" />

<int:service-activator input-channel="ch.http.in" output-channel="ch.aggr.obj" ref="httpToObjTransformer" method="transform"></int:service-activator>
<bean id="httpToObjTransformer" class="com.nevexis.dcard.integration.transformer.HttpToObjTransformer" />
</beans>

作为子GenericXmlApplicationContext

当子上下文加载时我可以看到

IntegrationRequestMappingHandlerMapping:197 - Mapped "{[/transaction],methods=[GET || POST],params=[],headers=[],consumes=[],produces=[],custom=[]}" onto public abstract void org.springframework.web.HttpRequestHandler.handleRequest(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) throws javax.servlet.ServletException,java.io.IOException

在日志中,但无法映射http://localhost:8081/transaction

最佳答案

那是因为DispatcherServlet是在单独的子上下文中定义的,并且看不到 IntegrationRequestMappingHandlerMapping bean 。

任何子上下文都可以从其ancestors中看到bean ,但不能从其他子上下文中获取,并且父上下文无法在您的子上下文中看到 bean。

需要理解为什么要在子上下文中声明集成流。为什么不是 <context:import>对你来说够了吗?

关于java - 子上下文中的 Spring Integration http 端点不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24310609/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com