1
我尝试在不同的罐子中使用弹簧集成。 在a.jar文件的SI-context.xml中:弹簧集成:未找到网关bean
<context:annotation-config />
<int:annotation-config />
<int:channel id="upperServiceChannel">
<int:priority-queue />
</int:channel>
<int:gateway id="upperGateway" default-request-timeout="5000"
default-reply-timeout="5000" default-request-channel="upperServiceChannel"
service-interface="com.company.proj.gw.IUpperStringConversation">
<int:method name="toUpperCase" />
</int:gateway>
<bean id="toUpperCaseService" class="com.company.proj.service.ToUpperCaseService" />
<int:service-activator id="serviceActivatorToUpperCase"
input-channel="upperServiceChannel" method="toUpperCase" ref="toUpperCaseService" />
<int:poller id="poller" default="true" fixed-delay="1000" />
<context:component-scan base-package="com.company"/>
在一个bean我使用这个网关:
@Component(value = "upper")
public class UpperAdapter extends AAdapter<Message<String>> {
@Autowired
IUpperStringConversation gw;
它的工作。问题是,如果我尝试从其他项目(B.jar)使用我的UpperAdapter。 B-context.xml中:
<import resource="classpath*:/*si-context.xml" />
<context:annotation-config />
<int:annotation-config />
@Component(value="router")
public class Router {
@Autowired
private Map<String, AAdapter<?>> adapters;
在这里,我得到:
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'upper': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: com.company.proj.gw.IUpperStringConversation com.company.proj.adapter.UpperAdapter.gw; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean of type [com.company.proj.gw.IUpperStringConversation] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
后,我设置的弹簧日志级别来调试,得到这样的信息:
DEBUG o.s.c.a.ClassPathBeanDefinitionScanner - Ignored because not a concrete top-level class: URL [jar:file:/home/tomto/Documents/workspace-sts/integration-fw/src/main/resources/META-INF/lib/integration-fw-module-string-0.0.1-SNAPSHOT.jar!/com/company/proj/gw/IUpperStringConversation.class]
当然,这是真的,因为(也许我错了;))它将在春天在运行时生成的网关。
的IUpperStringConversation:
public interface IUpperStringConversation {
public String toUpperCase(String text);
}
我错过了什么?
Thx!
为'org.springframework'开启DEBUG日志记录;你会得到丰富的调试日志xml解析,bean发现/创建等。 –
你有没有解决过这个问题? – EoD