简体   繁体   English

Spring Boot和ActiveMQ:忽略Broker-URL并使用默认的localhost:61616

[英]Spring Boot and ActiveMQ: Ignores broker-url and uses default localhost:61616

I'm using Spring Boot and ActiveMQ. 我正在使用Spring Boot和ActiveMQ。 In application.properties I set the url for activemq like this: 在application.properties中,我像这样设置activemq的网址:

spring.activemq.broker-url=vm://localhost?broker.persistent=false

As you can see I'm using an embedded broker (dependency added in pom). 如您所见,我正在使用嵌入式代理(在pom中添加了依赖性)。 This is my application class: 这是我的应用程序类:

@SpringBootApplication
@EntityScan(
    basePackageClasses = {ServiceApplication.class, Jsr310JpaConverters.class}
)
@EnableAutoConfiguration
@ServletComponentScan
public class ServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(ServiceApplication.class, args);
    }

}

These are the activemq related dependencies in the pom: 这些是pom中与activemq相关的依赖关系:

<dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-camel</artifactId>
        <version>5.14.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-pool</artifactId>
        <version>5.14.5</version>
    </dependency>
    <dependency>
        <groupId>org.apache.activemq</groupId>
        <artifactId>activemq-broker</artifactId>
        <version>5.14.5</version>
    </dependency>

I have a single application.properties, I don't have different profiles. 我只有一个application.properties,没有不同的配置文件。

But when I run the app, I get this log: 但是,当我运行该应用程序时,会收到以下日志:

[ActiveMQ Task-1] o.a.a.t.failover.FailoverTransport       : Failed to connect to [tcp://localhost:61616] after: 10 attempt(s) continuing to retry.

It's trying to connect to tcp://localhost:61616 even though that's not the url I defined. 它试图连接到tcp:// localhost:61616,即使这不是我定义的url。

I tried removing @EnableAutoConfiguration but still the same issue. 我尝试删除@EnableAutoConfiguration,但仍然是相同的问题。

How can I solve this? 我该如何解决?

Your ActiveMQ client is not aware of spring.activemq.broker-url since this property is used to configure spring-boot-starter-activemq.If you do not have this starter - you configure nothing with this property. 您的ActiveMQ客户端不知道spring.activemq.broker-url因为此属性用于配置spring-boot-starter-activemq。如果没有此启动器,则无需配置该属性。

I would suggest you to go through the following resources to have a better understanding of how to set up spring-boot-starter-activemq in your project: 我建议您阅读以下资源,以更好地了解如何在项目中设置spring-boot-starter-activemq:

Hope it helps! 希望能帮助到你!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM