作者:百色金融新闻网日期:
返回目录:金融新闻
最新资讯《spring boot 集成 activeMQ 关于 JmsTemplate的问题-activemq》主要内容是activemq,Field jmsTemplate in com.example.demo.web.ActiveMQController required a bean of type 'org.springframework.jms.core.JmsTemplate' that could n,现在请大家看具体新闻资讯。
错误信息
***************************
APPLICATION FAILED TO START
***************************
Description:
Field jmsTemplate in com.example.demo.web.ActiveMQController required a bean of type 'org.springframework.jms.core.JmsTemplate' that could not be found.
The injection point has the following annotations:
\t- @org.springframework.beans.factory.annotation.Autowired(required=true)
Action:
Consider defining a bean of type 'org.springframework.jms.core.JmsTemplate' in your configuration.
解决方法
手动配置JmsTemplate
@Configuration
public class JmsConfig {
@Bean
public ConnectionFactory connectionFactory() {
return new ActiveMQConnectionFactory();
}
@Bean
public JmsTemplate jmsTemplate(ConnectionFactory connectionFactory) {
JmsTemplate jmsTemplate = new JmsTemplate(connectionFactory);
jmsTemplate.setPriority(999);
return jmsTemplate;
}
@Bean(value="jmsMessagingTemplate")
public JmsMessagingTemplate jmsMessagingTemplate(JmsTemplate jmsTemplate) {
JmsMessagingTemplate messagingTemplate = new JmsMessagingTemplate(jmsTemplate);
return messagingTemplate;
}
}
本文标签:ActiveMQ(10)