Java RabbitMQ未在Spring引导中自动配置
当我查看Spring Boot官方文档时,它说Spring Boot将自动配置RabbitMQ并为Java RabbitMQ未在Spring引导中自动配置,java,spring,spring-boot,rabbitmq,Java,Spring,Spring Boot,Rabbitmq,当我查看Spring Boot官方文档时,它说Spring Boot将自动配置RabbitMQ并为RabbitTemplate生成一个bean,但是,当我使用@Autowired注入它时,应用程序无法启动,并向我发出以下错误消息: Field rabbitTemplate in xxx.xxx.queue.publisher.XXXPublisher required a bean of type 'org.springframework.amqp.rabbit.core.RabbitTempl
RabbitTemplate
生成一个bean,但是,当我使用@Autowired
注入它时,应用程序无法启动,并向我发出以下错误消息:
Field rabbitTemplate in xxx.xxx.queue.publisher.XXXPublisher required a bean of type 'org.springframework.amqp.rabbit.core.RabbitTemplate' that could not be found.
The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)
有人知道为什么它不自动配置吗?如果有任何答复,我将不胜感激
注:我在我的主要课程中注释了@SpringBootApplication
和@EnableAutoConfiguration
:
@SpringBootApplication
@EnableAutoConfiguration
@EnableTransactionManagement
@EnableRetry
@EnableAsync
@EnableScheduling
public class XXXApplication{
public static void main(String[] args) {
SpringApplication.run(XXXApplication.class, args);
}
}
事实证明,这是因为我在
应用程序.properties
文件中明确排除了RabbitAutoConfiguration
。您可以共享pom.xml文件和rabbitmq服务文件了解更多信息吗update@FazlanAhamed好,原来是因为我以前在application.properties文件中明确排除了RabbitAutoConfiguration。。。