SpringBoot中的RabbitMQ启动错误

时间:2016-04-24 16:50:32

标签: java spring spring-boot rabbitmq

一个月后我开始SpringBootApplication时,我的代码出错了。 它以前工作但现在我得到错误: HealthIndicatorAutoConfiguration $ RabbitHealthIndicatorConfiguration

  1. rabbitMQ实例正在我的VM中工作
  2. 可以从SpringBoot实例访问。
  3. health.rabbit.enabled=false添加到application.properties
  4. 有人知道这是什么类型的错误吗?

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$RabbitHealthIndicatorConfiguration': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.springframework.boot.actuate.health.HealthAggregator org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration$RabbitHealthIndicatorConfiguration.healthAggregator; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.HealthIndicatorAutoConfiguration': Initialization of bean failed; nested exception is java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
        at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1214) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:543) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772) ~[spring-beans-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538) ~[spring-context-4.2.5.RELEASE.jar:4.2.5.RELEASE]
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
        at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:307) ~[spring-boot-1.3.3.RELEASE.jar:1.3.3.RELEASE]
        at demo.SpringDemoApplication.main(SpringDemoApplication.java:13) [bin/:na]
    

    的build.gradle

    buildscript {
    ext {
        springBootVersion = '1.2.3.RELEASE'
    }
    repositories {
      mavenCentral()
      maven { url "https://repo.spring.io/libs-milestone" }
     }
     dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}") 
        classpath("io.spring.gradle:dependency-management-plugin:0.5.1.RELEASE")
    }
    }
    
    apply plugin: 'java'
    apply plugin: 'eclipse'
    apply plugin: 'idea'
    apply plugin: 'spring-boot' 
    
    jar {
    baseName = 'spring-demo'
    version = '0.0.1-SNAPSHOT'
    }
    sourceCompatibility = 1.8
    targetCompatibility = 1.8
    
    repositories {
    mavenCentral()
    }
    
    dependencies {
    compile("org.springframework.boot:spring-boot-starter")
    compile("org.springframework.boot:spring-boot-starter-parent")
    compile("org.springframework.boot:spring-boot-starter-actuator")
    compile("org.springframework.boot:spring-boot-starter-test")
    
    // web
    compile("org.springframework.boot:spring-boot-starter-web")
    // batch
    compile("org.springframework.boot:spring-boot-starter-batch")
    
    // mongo
    compile("org.springframework.boot:spring-boot-starter-data-mongodb")
    compile("org.mongodb:mongo-java-driver")
    
    // lombok
    compile("org.projectlombok:lombok:1.16.4")
    
    // template change to use my thymleaf
    compile("org.springframework.boot:spring-boot-starter-thymeleaf")
    compile('org.unbescape:unbescape:1.1.1.RELEASE');
    //compile('net.sourceforge.nekohtml:nekohtml:1.9.22')
    
    //  session
    compile("org.springframework.session:spring-session:1.0.1.RELEASE")
    compile("org.springframework.boot:spring-boot-starter-redis:1.2.4.RELEASE")
    compile("org.springframework.session:spring-session-data-redis:1.0.1.RELEASE")
    compile("org.springframework.data:spring-data-redis:1.4.1.RELEASE")
    compile("redis.clients:jedis:2.4.1")
    
    //  face book
    compile("org.springframework.social:spring-social-facebook")
    
    //  standford
    compile('edu.stanford.nlp:stanford-parser:3.5.2')
    compile('edu.stanford.nlp:stanford-corenlp:3.5.2')
    compile('edu.stanford.nlp:stanford-corenlp:3.5.2:models')
    compile('edu.washington.cs.knowitall.stanford-corenlp:stanford-parse-models:1.3.2')
    
    //  JMS
    compile('org.springframework:spring-jms:4.2.2.RELEASE')
    compile('org.apache.activemq:activemq-broker:5.12.1')
    
    // Rabbit MQ with JMS
    compile("org.springframework.boot:spring-boot-starter-amqp")
    
    //  Kuromoji
    compile("org.apache.lucene:lucene-core:5.5.0")
    compile("org.apache.lucene:lucene-analyzers-kuromoji:5.5.0")
    
    //  mahout
    compile("org.apache.mahout:mahout-core:0.9")
    
    //  aws
    //compile('org.springframework.cloud:spring-cloud-starter:1.0.1.RELEASE')
    //compile('org.springframework.cloud:spring-cloud-aws-context:1.0.1.RELEASE')
    //compile('org.springframework.cloud:spring-cloud-aws-autoconfigure:1.0.1.RELEASE')
    
    //  security
    //compile('org.springframework.boot:spring-boot-starter-security')
    
    //  thymeleaf
    // for this time , this referes local project
    // org.thymeleaf:thymeleaf:2.1.4.RELEASE
    //compile('ognl:ognl:3.0.8');
    //compile('org.unbescape:unbescape:1.1.0.RELEASE')
    //compile('org.springframework.boot:spring-boot-starter-thymeleaf:1.2.3.RELEASE');
    //compile('nz.net.ultraq.thymeleaf:thymeleaf-layout-dialect:1.2.7');
    /*compile("org.springframework.boot:spring-boot-starter-thymeleaf"){
        // this setting is for the local debugging thymeleaf
        exclude group: 'org.thymeleaf', module: 'thymeleaf-spring4'
        exclude group: 'org.thymeleaf', module: 'thymeleaf'
    }*/
    
    compile('org.springframework.boot:spring-boot-starter-data-jpa:1.3.3.RELEASE');
    compile('com.h2database:h2:1.4.191');
    
    
    testCompile("junit:junit")
    
    }
    
    configurations {
    }
    
    
    task wrapper(type: Wrapper) {
    gradleVersion = '2.3'
    }
    
    eclipse {
    classpath {
         containers.remove('org.eclipse.jdt.launching.JRE_CONTAINER')
         containers 'org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7'
    }
    }
    
    springBoot {
    mainClass = "demo.SpringDemoApplication"
    }
    

    我的兔子配置

    package demo.configs;
    
    import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
    import org.springframework.amqp.rabbit.connection.ConnectionFactory;
    import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
    import org.springframework.context.annotation.Bean;
    
    public class RabbitMQConfig {
    
    @Bean
    CachingConnectionFactory rabbitConnectionFactory(){
        CachingConnectionFactory rabicon = new CachingConnectionFactory();
        //amqp.connect('amqp://admin:admin@192.168.3.3:5672/',
        //rabicon.setHost("192.168.3.3");
        rabicon.setHost(Const.Rabbit_Host);
        rabicon.setUsername(Const.Rabbit_User);
        rabicon.setPassword(Const.Rabbit_Pass);
        rabicon.setPort(5672);
        return rabicon;
    }
    
    @Bean
    SimpleMessageListenerContainer simpleMessage(ConnectionFactory connectionFactory) {
        SimpleMessageListenerContainer container = new SimpleMessageListenerContainer();
        container.setConnectionFactory(connectionFactory);
        container.setQueueNames(Const.RabbitMQMessageQue);
        //container.setMessageListener(listenerAdapter);
        return container;
    }
    }
    

0 个答案:

没有答案