簡體   English   中英

我嘗試在春季引導中使用undertow,但這是錯誤的

[英]I try use undertow in spring boot ,but it's error

我開始用underwow容器啟動彈簧。 這是錯誤的消息

10:17:49.123 [main] ERROR org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroy method on bean with name 'org.springframework.context.annotation.internalScheduledAnnotationProcessor' threw an exception
10:17:49.128 [main] ERROR org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroy method on bean with name 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor' threw an exception
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@71ba6d4e: startup date [Tue Dec 06 10:17:46 CST 2016]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) [spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554) [spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:954) [spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523) [spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:961) [spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1033) [spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:555) [spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175) [spring-boot-1.4.2.RELEASE.jar:1.4.2.RELEASE]
    at com.test.Application.main(Application.java:34) [main/:?]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_92]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_92]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_92]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_92]
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147) [idea_rt.jar:?]
10:17:49.128 [main] ERROR org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroy method on bean with name 'org.springframework.boot.context.properties.ConfigurationPropertiesBindingPostProcessor' threw an exception
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@71ba6d4e: startup date [Tue Dec 06 10:17:46 CST 2016]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578) [spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
10:17:49.129 [main] ERROR org.springframework.beans.factory.support.DefaultListableBeanFactory - Destroy method on bean with name 'org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory' threw an exception
java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call 'refresh' before multicasting events via the context: org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@71ba6d4e: startup date [Tue Dec 06 10:17:46 CST 2016]; root of context hierarchy
    at org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97) ~[spring-context-4.3.4.RELEASE.jar:4.3.4.RELEASE]
10:17:49.133 [main] ERROR org.springframework.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'embeddedServletContainerCustomizerBeanPostProcessor': BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cache.annotation.ProxyCachingConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cachingConfig' defined in file [D:\workspace\test\build\classes\main\com\test\config\CachingConfig.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:478) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.cache.annotation.ProxyCachingConfiguration': Unsatisfied dependency expressed through method 'setConfigurers' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'cachingConfig' defined in file [D:\workspace\test\build\classes\main\com\test\config\CachingConfig.class]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class org.hibernate.validator.internal.engine.ConfigurationImpl
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredMethodElement.inject(AutowiredAnnotationBeanPostProcessor.java:671) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:370) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1219) ~[spring-beans-4.3.4.RELEASE.jar:4.3.4.RELEASE]

的build.gradle

configurations {
    compile.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-logging'
    compile.exclude group: 'org.springframework.boot', module: 'spring-boot-starter-tomcat'
}

task wrapper(type: Wrapper) {
    gradleVersion = '3.1'
}

dependencies {
    providedRuntime(
            'org.springframework.boot:spring-boot-starter-undertow:1.4.2.RELEASE'
    )
    testCompile(
            'junit:junit:4.11',
            "org.springframework.boot:spring-boot-starter-test:1.4.2.RELEASE",
            'org.spockframework:spock-core:1.1-groovy-2.4-rc-1',
            'org.spockframework:spock-spring:1.1-groovy-2.4-rc-1',
            //微基准測試
            'org.openjdk.jmh:jmh-core:1.13',
            'org.openjdk.jmh:jmh-generator-annprocess:1.13'
    )
    compile(
            'org.springframework.boot:spring-boot-starter:1.4.2.RELEASE',
            'org.springframework.boot:spring-boot-starter-web:1.4.2.RELEASE',
//            'org.springframework.boot:spring-boot-starter-jersey:1.4.2.RELEASE',
            'org.springframework.boot:spring-boot-starter-validation:1.4.2.RELEASE',
            'org.springframework.boot:spring-boot-starter-actuator:1.4.2.RELEASE',
            'org.springframework.boot:spring-boot-starter-jdbc:1.4.2.RELEASE',
            'org.springframework.boot:spring-boot-starter-log4j2:1.4.2.RELEASE',
            'org.springframework.boot:spring-boot-configuration-processor:1.4.2.RELEASE',
            'org.springframework.boot:spring-boot-starter-data-mongodb:1.4.2.RELEASE',
            'org.springframework.boot:spring-boot-starter-data-redis:1.4.2.RELEASE',
            'org.springframework.boot:spring-boot-starter-mail:1.4.2.RELEASE',
            'org.springframework.boot:spring-boot-starter-aop:1.4.2.RELEASE',
            'org.springframework.boot:spring-boot-starter-data-rest:1.4.2.RELEASE',
            'org.springframework.boot:spring-boot-starter-freemarker:1.4.2.RELEASE',
            'org.codehaus.groovy:groovy-all:2.4.7',
            'cglib:cglib-nodep:3.2.4',
            'org.objenesis:objenesis:2.4',
            //異步日志支持
            'com.lmax:disruptor:3.3.4',
            //mybatis
            'org.mybatis:mybatis:3.3.1',
            'org.mybatis:mybatis-spring:1.2.4',
            'com.github.pagehelper:pagehelper:4.1.3',
            //mysql
            'mysql:mysql-connector-java:5.1.38',
            //數據庫連接池
            'com.alibaba:druid:1.0.18',
            //java工具類
            'com.google.guava:guava:19.0',

            // apache的commons工具類
            'commons-io:commons-io:2.4',
            'org.apache.commons:commons-lang3:3.4',
            'commons-codec:commons-codec:1.10',
            'commons-fileupload:commons-fileupload:1.3.1',
            'commons-beanutils:commons-beanutils:1.9.2',
            //java guava工具類
            'com.google.guava:guava:19.0',
            //java collections 工具類
            'org.eclipse.collections:eclipse-collections:8.0.0-M1',
            'org.eclipse.collections:eclipse-collections-testutils:8.0.0-M1',
            //操作redis
            'redis.clients:jedis:2.8.1',
            //json
            'com.fasterxml.jackson.core:jackson-databind:2.7.3',
            'com.fasterxml.jackson.core:jackson-core:2.7.3',
            'com.fasterxml.jackson.core:jackson-annotations:2.7.3',
            'com.fasterxml.jackson.module:jackson-module-jaxb-annotations:2.7.3',
            //pojo copy
            'net.sf.dozer:dozer:5.5.1',
            //image util
            //metadata-extractor is a straightforward Java library for reading metadata from image files.
            'com.drewnoakes:metadata-extractor:2.8.1',
            //Thumbnailator is a thumbnail generation library for Java.
            'net.coobird:thumbnailator:0.4.8',
            //二維碼
            'com.google.zxing:core:3.2.1',
            'com.google.zxing:javase:3.2.1',
            //shiro
            'org.apache.shiro:shiro-core:1.2.4',
            'org.apache.shiro:shiro-web:1.2.4',
            'org.apache.shiro:shiro-ehcache:1.2.4',
            'org.apache.shiro:shiro-spring:1.2.4',
            'org.apache.shiro:shiro-cas:1.2.4',
            //ant
            'org.apache.ant:ant:1.9.6',

            //servlet
            'javax.servlet:javax.servlet-api:4.0.0-b01',
            'javax.servlet.jsp:jsp-api:2.2.1-b03',
            //管理項目中API接口
            'com.mangofactory:swagger-springmvc:1.0.2',
            'io.springfox:springfox-swagger2:2.5.0',
            //http 請求工具
            'com.sun.jersey:jersey-core:1.19.2',
            'com.sun.jersey:jersey-client:1.19.2',
            'com.sun.jersey.contribs:jersey-multipart:1.19.2'
    )
}

但是我的項目incloud驗證器jar。 如果我添加此代碼

//  @Bean
//  public UndertowEmbeddedServletContainerFactory embeddedServletContainerFactory() {
//    UndertowEmbeddedServletContainerFactory factory = new UndertowEmbeddedServletContainerFactory();
//    factory.addBuilderCustomizers(builder -> builder.addHttpListener(80, "0.0.0.0")
//        .setServerOption(UndertowOptions.ENABLE_HTTP2, true));
//    return factory;

錯誤:java.lang.ClassNotFoundException:io.undertow.Undertow $ Builder

如果我使用tocmat或jetty,那么我不確定是Spring Boot還是Undertow問題。

這是我的圖書館清單這是我的圖書館清單

我已解決該錯誤:

原因:java.lang.NoClassDefFoundError:無法初始化類org.hibernate.validator.internal.engine.ConfigurationImpl

添加此缺少的依賴項:

    <dependency>
        <groupId>org.jboss.logging</groupId>
        <artifactId>jboss-logging</artifactId>
        <version>3.2.0.Final</version>
    </dependency>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM