使用Vaadin 8 Push和Spring Boot 1.5.1版的NoClassDefFoundError

时间:2017-03-07 13:01:13

标签: spring-boot vaadin-push vaadin8

使用Spring Boot版本1.5.1.RELEASE启用Vaadin 8 Push时出现以下错误。

java.lang.NoClassDefFoundError: org/springframework/boot/context/embedded/ServletListenerRegistrationBean
        at java.lang.Class.getDeclaredMethods0(Native Method)
        at java.lang.Class.privateGetDeclaredMethods(Class.java:2701)
        at java.lang.Class.getDeclaredMethods(Class.java:1975)
        at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:613)
        at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:524)
        at org.springframework.util.ReflectionUtils.doWithMethods(ReflectionUtils.java:510)
        at org.springframework.util.ReflectionUtils.getUniqueDeclaredMethods(ReflectionUtils.java:570)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.getTypeForFactoryMethod(AbstractAutowireCapableBeanFactory.java:697)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:640)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:609)
        at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1484)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:425)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:395)
        at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:96)
        at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)
        at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:314)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1162)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1151)
        at com.xxxx.yyy.Application.main(Application.java:37)
Caused by: java.lang.ClassNotFoundException: org.springframework.boot.context.embedded.ServletListenerRegistrationBean
        at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
        ... 23 common frames omitted

这是build.gradle

buildscript {
    ext {
        springBootVersion = '1.5.1.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

jar {
    baseName = 'test'
    version = '0.0.1-SNAPSHOT'
}

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-jersey')
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')

    // Spring Boot Security
  compile("org.springframework.boot:spring-boot-starter-security")
  compile("org.springframework.security.oauth:spring-security-oauth2")
  compile('org.springframework.security:spring-security-ldap')

  // Spring Actuator
  compile("org.springframework.boot:spring-boot-starter-actuator")

  // Vaadin
  compile('com.vaadin:vaadin-spring-boot-starter')
  compile('com.vaadin:vaadin-push')

  // Vaadin add-ons
  compile("org.vaadin.spring.addons:vaadin-spring-addon-eventbus:0.0.7.RELEASE")
  compile("org.vaadin.spring.addons:vaadin-spring-addon-mvp:0.0.7.RELEASE")
  compile("org.vaadin.spring.addons:vaadin-spring-addon-i18n:0.0.7.RELEASE")

  //Vaadin extentions - in the future more of those will go to official VaadinSpring Integration
  compile("org.vaadin.spring.extensions:vaadin-spring-ext-security:0.0.7.RELEASE")
  compile("org.vaadin.spring.extensions:vaadin-spring-ext-core:0.0.7.RELEASE")
  compile("org.vaadin.spring.extensions:vaadin-spring-ext-boot:0.0.7.RELEASE")
  compile("org.vaadin.spring.extensions:vaadin-spring-ext-test:0.0.7.RELEASE")

  // lombok
  compileOnly('org.projectlombok:lombok')

}

dependencyManagement {
    imports {
        mavenBom "com.vaadin:vaadin-bom:8.0.0"
    }
}

如果我禁用编译('com.vaadin:vaadin-push'),则没有错误但推送不起作用。 你知道如何使用Vaadin 8和Spring Boot 5进行推送工作吗?

3 个答案:

答案 0 :(得分:0)

这是a known issue,请订阅以进行更新。

答案 1 :(得分:0)

此类自Spring Boot 1.4以来已被弃用,并在1.5版本中删除。降级到Spring Boot 1.4.5.RELEASE并等待Vaadin使用正确的类。

答案 2 :(得分:0)

当我升级到Vaadin4Spring 2.0.0.RELEASE时,此问题已得到解决。

编译(" org.vaadin.spring.addons:vaadin弹簧 - 附加eventbus:2.0.0.RELEASE&#34)   编译(" org.vaadin.spring.extensions:vaadin弹簧-EXT-安全:2.0.0.RELEASE&#34)