Spring boot SpringBootJMS没有可用的JMSTemplatebean
我正在尝试从我的应用程序发送一条带有JMS的消息 我加入我的pomSpring boot SpringBootJMS没有可用的JMSTemplatebean,spring-boot,spring-jms,Spring Boot,Spring Jms,我正在尝试从我的应用程序发送一条带有JMS的消息 我加入我的pom <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jms</artifactId> </dependency> <dependency> <groupId>javax.jm
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jms</artifactId>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>jms</artifactId>
<version>1.1</version>
</dependency>
我尝试添加@EnableJMS(即使它只是针对侦听器…)
但它不起作用
我不明白为什么,在教程中看起来很容易…要工作,我们需要创建一个jmsTemplate bean
@Bean
public ConnectionFactory getConnectionFactory() {
TibjmsConnectionFactory connectionFactory = new TibjmsConnectionFactory(urlBrocker);
return connectionFactory;
}
@Bean
public JmsTemplate jmsTemplate() {
JmsTemplate template = new JmsTemplate();
template.setConnectionFactory(getConnectionFactory());
template.setPubSubDomain(false); // false for a Queue, true for a Topic
return template;
}
使用
--debug
运行启动应用程序以查看自动配置报告。若要添加它,只需添加activemq代理即可。。。我误解了JMS>\你能发布你的工作代码吗?我的仍不工作您必须添加一个bean jmstemplate
@Bean
public MessageConverter jacksonJmsMessageConverter() {
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setTargetType(MessageType.TEXT);
converter.setTypeIdPropertyName("_type");
return converter;
}
@Bean
public ConnectionFactory getConnectionFactory() {
TibjmsConnectionFactory connectionFactory = new TibjmsConnectionFactory(urlBrocker);
return connectionFactory;
}
@Bean
public JmsTemplate jmsTemplate() {
JmsTemplate template = new JmsTemplate();
template.setConnectionFactory(getConnectionFactory());
template.setPubSubDomain(false); // false for a Queue, true for a Topic
return template;
}