通过spring进行配置时是否需要启动ActiveMQ?

通过spring进行配置时是否需要启动ActiveMQ?,activemq,spring-jms,Activemq,Spring Jms,当我尝试使用SpringJMS集成测试activemq时,出现连接被拒绝错误。我需要启动activemq服务器还是什么?据我所知,当我设置brokerconnction时,spring将拥有启动活动mq的所有方法 来源 错误 如果使用vm://localhostURL,则会在vm传输上启动内存中的代理;如果您使用tcp://...url您需要启动一个外部代理,或将代理bean添加到应用程序中 @SpringBootApplication @EnableJms public class Appli

当我尝试使用SpringJMS集成测试activemq时,出现连接被拒绝错误。我需要启动activemq服务器还是什么?据我所知,当我设置brokerconnction时,spring将拥有启动活动mq的所有方法

来源 错误
如果使用
vm://localhost
URL,则会在vm传输上启动内存中的代理;如果您使用
tcp://...
url您需要启动一个外部代理,或将代理bean添加到应用程序中

@SpringBootApplication
@EnableJms
public class Application {
    @Bean
    public DefaultJmsListenerContainerFactory myJmsContainerFactory() {
        DefaultJmsListenerContainerFactory factory = new DefaultJmsListenerContainerFactory();
        factory.setConnectionFactory(connectionFactory());
        return factory;
    }
    @Bean
    public JmsTemplate jmsTemplate(){
        JmsTemplate jmsTemplate = new JmsTemplate();
        jmsTemplate.setDefaultDestination(new ActiveMQQueue("jms.queue"));
        jmsTemplate.setConnectionFactory(connectionFactory());
        return jmsTemplate;
    }

    @Bean
    public ActiveMQConnectionFactory connectionFactory(){
        ActiveMQConnectionFactory activeMQConnectionFactory = new ActiveMQConnectionFactory("tcp://:61616");
        activeMQConnectionFactory.setBrokerURL("tcp://localhost:61616");
        return activeMQConnectionFactory;
    }
    public static void main(String[] args){
        // Clean out any ActiveMQ data from previous run
        FileSystemUtils.deleteRecursively(new File("activemq-data"));

        // Launch the application
        ConfigurableApplicationContext context = SpringApplication.run(Application.class, args);

        // Send a message
        MessageCreator messageCreator = new MessageCreator() {

            @Override
            public Message createMessage(Session session) throws JMSException {
                return session.createTextMessage("ping!");
            }
        };

        JmsTemplate jmsTemplate = context.getBean(JmsTemplate.class);
        System.out.println("Sending a new message");
        jmsTemplate.send("mailbox-destination", messageCreator);
    }
}
Exception in thread "main" org.springframework.jms.UncategorizedJmsException: Uncategorized exception occured during JMS processing; nested exception is javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused
    at org.springframework.jms.support.JmsUtils.convertJmsAccessException(JmsUtils.java:316)
    at org.springframework.jms.support.JmsAccessor.convertJmsAccessException(JmsAccessor.java:169)
    at org.springframework.jms.core.JmsTemplate.execute(JmsTemplate.java:497)
    at org.springframework.jms.core.JmsTemplate.send(JmsTemplate.java:580)
    at org.blanc.whiteboard.jms.Application.main(Application.java:67)
Caused by: javax.jms.JMSException: Could not connect to broker URL: tcp://localhost:61616. Reason: java.net.ConnectException: Connection refused