Java SpringJMS junit测试可以';找不到@Component注释接收器
我正在尝试测试JMSSender和JMSReceiver,JMSSender是自动连接正确的,但JMSReceiver不是 没有类型为的限定bean “br.com.framework.TestJMSReceiverImpl”可从以下网址获得: 至少需要1个符合autowire候选资格的bean 测试类:Java SpringJMS junit测试可以';找不到@Component注释接收器,java,spring,junit,jms,autowired,Java,Spring,Junit,Jms,Autowired,我正在尝试测试JMSSender和JMSReceiver,JMSSender是自动连接正确的,但JMSReceiver不是 没有类型为的限定bean “br.com.framework.TestJMSReceiverImpl”可从以下网址获得: 至少需要1个符合autowire候选资格的bean 测试类: @RunWith(SpringRunner.class) @DirtiesContext @ContextConfiguration(classes = { JMSSenderConfig.c
@RunWith(SpringRunner.class)
@DirtiesContext
@ContextConfiguration(classes = { JMSSenderConfig.class, JMSReceiverConfig.class })
@TestPropertySource(properties = { "spring.activemq.broker-url = vm://localhost:61616" })
public class SpringJmsApplicationTest {
@ClassRule
public static EmbeddedActiveMQBroker broker = new EmbeddedActiveMQBroker();
@Autowired
private JMSSender sender;
@Autowired
private TestJMSReceiverImpl receiver;
@Test
public void testReceive() throws Exception {
sender.send("helloworld.q", "Daleee");
receiver.receive();
}
}
我的主要应用类别有:
@Configuration
@ComponentScan("br.com.framework")
@EnableAutoConfiguration(exclude = { BatchAutoConfiguration.class, DataSourceAutoConfiguration.class })
@SpringBootApplication
public class Application extends SpringBootServletInitializer {
TestJMSReceiverImpl:
@Component
public class TestJMSReceiverImpl extends JMSReceiver {
public TestJMSReceiverImpl() {
super("helloworld.q");
}
...
}
JMS接收器:
public abstract class JMSReceiver {
@Autowired
JmsTemplate jmsTemplate;
private String queue;
public JMSReceiver(String queue) {
this.queue = queue;
}
...
}
有人知道我这里缺少什么吗?测试上下文中不包括
TestJMSReceiverImpl
类。您需要将其添加到SpringJmsApplicationTest
class:change的上下文配置中
@ContextConfiguration(classes = { JMSSenderConfig.class, JMSReceiverConfig.class })
进入
扫描时是否包括
TestJMSReceiverImpl
?(它在正确的包中吗?)它在包br.com.framework上,我想它是正确的。。
@ContextConfiguration(classes = { JMSSenderConfig.class,
JMSReceiverConfig.class, TestJMSReceiverImpl.class })