에서 콩을 autowire하기하지 않습니다MDB 내가 WMQ에 연결하기 위해 다음과 같은 MDB를 사용하고 다른 패키지
@MessageDriven(name = "EventListener", activationConfig = {
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "destination", propertyValue = "ABC"),
@ActivationConfigProperty(propertyName = "hostName", propertyValue = "ABC"),
@ActivationConfigProperty(propertyName = "port", propertyValue = "ABC"),
@ActivationConfigProperty(propertyName = "channel", propertyValue = "ABC"),
@ActivationConfigProperty(propertyName = "queueManager", propertyValue = "ABC"),
@ActivationConfigProperty(propertyName = "sslCipherSuite", propertyValue = "ABC"),
@ActivationConfigProperty(propertyName = "transportType", propertyValue = "CLIENT") })
@ResourceAdapter(value = "wmq.jmsra.rar")
@TransactionManagement(value = TransactionManagementType.CONTAINER)
@TransactionAttribute(value = TransactionAttributeType.REQUIRED)
@Interceptors(SpringBeanAutowiringInterceptor.class)
public class EventListener implements MessageListener {}
다음 봄 콩 MDB 위에 사용되는 인터셉터 주석의 일환으로 autowire가되고있다. 이벤트 앱 config.xml 파일은 :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:component-scan base-package="com.abc" />
<context:annotation-config/>
<import resource="classpath:core-app-config.xml" /> //This is another package
</beans>
에 따라 코어 - 앱 config.xml에 있습니다 :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:cache="http://www.springframework.org/schema/cache"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/cache
http://www.springframework.org/schema/cache/spring-cache.xsd">
<import resource="classpath:database-config.xml" />
<import resource="classpath:spring-jms-config.xml" />
</beans>
홈페이지 XML을 beanRefContext.xml로 :
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xsi:schemaLocation="http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<context:annotation-config/>
<context:spring-configured/>
<bean id="beanRefFactory" class="org.springframework.context.support.ClassPathXmlApplicationContext">
<constructor-arg value="classpath*:event-app-config.xml" />
</bean>
</beans>
내가 autowiring에 있어요 MDB 패키지에있는 & spring jms xmls 데이터베이스의 특정 빈 인스턴스가 있지만이 XML 내부의 모든 빈은 만들어지지 않은 것처럼 보입니다. 문제가 될 수있는 점을 이해해 주시겠습니까? MDB의 autowire 기능이 동일한 패키지의 spring xmls로 제한되고, parent spring bean xml 내에서 수행되는 다른 imports가 생성되지 않습니까?
예 : EventListener
은 com.abc.xyz
패키지입니다. 나는 com.abc.core 패키지에서 이벤트 리스너 클래스의 클래스 A
인스턴스를 autowiring하고있다. 클래스 A
은 @Service
이고 차례로 com.abc.packB
에있는 클래스 B
이 자동 종속 종속성을가집니다. 그래서 클래스 A
의 인스턴스가 생성 될 때 아무런 클래스 B
정의가 발견되지 않는다는 예외가 발생합니다.
EventListener는 어떤 패키지입니까? – msknapp
이 com.abc.xyz에 있고 핵심 xml, 데이터베이스 및 스프링이 com.abc.core에 있습니다. –
자동 배선 재료가 보이지 않습니다 (예 :'@ Autowired '또는'@ Inject'). 'SpringBeanAutowiringInterceptor'를 사용할 때, 설정을 포함하고있는 모든 xml 파일을로드하는'beanRefContext.xml' 파일이 필요합니다. 'ContextLoaderListener'를 사용하지 않습니다. SpringBeanAutowiringInterceptor의 [documentation] (http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/ejb/interceptor/SpringBeanAutowiringInterceptor.html)에 설명되어 있습니다. –