运行Grails项目时出错

时间:2017-05-29 16:32:57

标签: java spring grails spring-boot

我的grailsVersion = 3.3.0.M1和gradleWrapperVersion = 3.0有问题。每当我运行项目时,我都会收到以下错误。

  

|解决依赖关系。请等一下......

     

配置成功

     

总时间:13.543秒|运行应用程序... 2017-05-29   22:08:46.634 ERROR --- [main] o.s.boot.SpringApplication
  :应用程序启动失败

     

java.lang.NoClassDefFoundError:   org / springframework / boot / context / embedded / FilterRegistrationBean at   asset.pipeline.AssetPipelineGrailsPlugin $ _doWithSpring_closure1.doCall(AssetPipelineGrailsPlugin.groovy:105)     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at   sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)     在   sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)     在java.lang.reflect.Method.invoke(Method.java:498)at   org.springsource.loaded.ri.ReflectiveInterceptor.jlrMethodInvoke(ReflectiveInterceptor.java:1426)     在   org.codehaus.groovy.reflection.CachedMethod.invoke(CachedMethod.java:93)     在groovy.lang.MetaMethod.doMethodInvoke(MetaMethod.java:325)at   org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:294)     at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:1027)     在groovy.lang.Closure.call(Closure.java:414)at   groovy.lang.Closure.call(Closure.java:408)at   grails.spring.BeanBuilder.invokeBeanDefiningClosure(BeanBuilder.java:759)     在grails.spring.BeanBuilder.beans(BeanBuilder.java:588)at   grails.spring.BeanBuilder.invokeMethod(BeanBuilder.java:531)at   org.grails.plugins.DefaultGrailsPlugin.doWithRuntimeConfiguration(DefaultGrailsPlugin.java:559)     在   org.grails.plugins.AbstractGrailsPluginManager.doRuntimeConfiguration(AbstractGrailsPluginManager.java:167)     在   grails.boot.config.GrailsApplicationPostProcessor.postProcessBeanDefinitionRegistry(GrailsApplicationPostProcessor.groovy:171)     在   org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate.java:118)     在   org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)     在   org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)     在   org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)     在   org.springframework.boot.SpringApplication.refresh(SpringApplication.java:737)     在   org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:370)     在   org.springframework.boot.SpringApplication.run(SpringApplication.java:314)     在grails.boot.GrailsApp.run(GrailsApp.groovy:83)at   grails.boot.GrailsApp.run(GrailsApp.groovy:388)at   grails.boot.GrailsApp.run(GrailsApp.groovy:375)at   grails.boot.GrailsApp $ run.call(未知来源)at   org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)     在   org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)     在   org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)     在mjmdashboardnext.Application.main(Application.groovy:8)引起:   抛出java.lang.ClassNotFoundException:   org.springframework.boot.context.embedded.FilterRegistrationBean 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 at   java.lang.ClassLoader.loadClass(ClassLoader.java:357)... 33常见   框架省略

     

2017-05-29 22:08:46.749错误--- [主要]   o.s.b.f.s.DefaultListableBeanFactory:用bean销毁bean的方法   name' grailsApplicationPostProcessor'抛出异常

     

java.lang.IllegalStateException:ApplicationEventMulticaster没有   初始化 - 调用'刷新'在通过网络多播事件之前   背景:   org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@64c2b546:   启动日期[Mon May 29 22:08:08 NPT 2017];上下文层次结构的根     在   org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404)     在   org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97)     在   org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253)     在   org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)     在   org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)     在   org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961)     在   org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)     在   org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968)     在   org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1033)     在   org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1009)     在   org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961)     在   org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:794)     在   org.springframework.boot.SpringApplication.run(SpringApplication.java:325)     在grails.boot.GrailsApp.run(GrailsApp.groovy:83)at   grails.boot.GrailsApp.run(GrailsApp.groovy:388)at   grails.boot.GrailsApp.run(GrailsApp.groovy:375)at   grails.boot.GrailsApp $ run.call(未知来源)at   org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)     在   org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)     在   org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)     在mjmdashboardnext.Application.main(Application.groovy:8)

     

2017-05-29 22:08:46.765错误--- [主要]   o.s.b.f.s.DefaultListableBeanFactory:用bean销毁bean的方法   名称   ' org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory'   抛出异常

     

java.lang.IllegalStateException:ApplicationEventMulticaster没有   初始化 - 调用'刷新'在通过网络多播事件之前   背景:   org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@64c2b546:   启动日期[Mon May 29 22:08:08 NPT 2017];上下文层次结构的根     在   org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404)     在   org.springframework.context.support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97)     在   org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter.java:253)     在   org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)     在   org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegistry.java:554)     在   org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:961)     在   org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)     在   org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:968)     在   org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1033)     在   org.springframework.context.support.AbstractApplicationContext.doClose(AbstractApplicationContext.java:1009)     在   org.springframework.context.support.AbstractApplicationContext.close(AbstractApplicationContext.java:961)     在   org.springframework.boot.SpringApplication.handleRunFailure(SpringApplication.java:794)     在   org.springframework.boot.SpringApplication.run(SpringApplication.java:325)     在grails.boot.GrailsApp.run(GrailsApp.groovy:83)at   grails.boot.GrailsApp.run(GrailsApp.groovy:388)at   grails.boot.GrailsApp.run(GrailsApp.groovy:375)at   grails.boot.GrailsApp $ run.call(未知来源)at   org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)     在   org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)     在   org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:133)     在mjmdashboardnext.Application.main(Application.groovy:8)

     

失败:构建因异常而失败。

     
      
  • 出了什么问题:任务执行失败':bootRun'。

         
        

    进程'命令' C:\ Program Files \ Java \ jdk1.8.0_121 \ bin \ java.exe''完成非零退出值1

      
  •   
  • 尝试:使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获取更多日志输出。错误|无法启动服务器(使用--stacktrace查看完整跟踪)

  •   
     

使用退出代码1完成处理

我曾尝试在build.gradle中升级我的插件,但错误仍然相同。

我的build.gradle如下

buildscript {
    repositories {
        mavenLocal()
        maven { url "https://repo.grails.org/grails/core" }
    }
    dependencies {
        classpath "org.grails:grails-gradle-plugin:$grailsVersion"
        classpath "org.grails.plugins:hibernate5:6.0.7"
        classpath "org.grails.plugins:views-gradle:1.1.5"
        classpath 'com.bertramlabs.plugins:asset-pipeline-gradle:2.10.1'
        classpath "org.grails.plugins:views-gradle:1.2.0"
    } }

version "0.5.1" group "test"

apply plugin:"eclipse" apply plugin:"idea" apply plugin:"war" apply plugin:"org.grails.grails-web" apply plugin:"org.grails.plugins.views-json"

repositories {
    mavenLocal()
    maven { url "https://repo.grails.org/grails/core" }
    maven { url 'http://dl.bintray.com/agorapulse/libs' } }

dependencyManagement {
    imports {
        mavenBom "org.grails:grails-bom:$grailsVersion"
    }
    applyMavenExclusions false }

dependencies {
    compile "org.springframework.boot:spring-boot-starter-logging"
    compile "org.springframework.boot:spring-boot-autoconfigure"
    compile "org.grails:grails-core"
    compile "org.springframework.boot:spring-boot-starter-actuator"
    compile "org.springframework.boot:spring-boot-starter-tomcat"
    compile "org.grails:grails-plugin-url-mappings"
    compile "org.grails:grails-plugin-rest"
    compile "org.grails:grails-plugin-codecs"
    compile "org.grails:grails-plugin-interceptors"
    compile "org.grails:grails-plugin-services"
    compile "org.grails:grails-plugin-datasource"
    compile "org.grails:grails-plugin-databinding"
    compile "org.grails:grails-plugin-async"
    compile "org.grails:grails-web-boot"
    compile "org.grails:grails-logging"
    compile "org.grails.plugins:cache"
    compile "org.grails.plugins:hibernate5"
    compile "org.hibernate:hibernate-core:5.1.2.Final"
    compile "org.hibernate:hibernate-ehcache:5.1.2.Final"
    compile "org.grails.plugins:views-json:1.2.1"
    compile "org.grails.plugins:views-json-templates:1.2.1"
    console "org.grails:grails-console"
    profile "org.grails.profiles:rest-api"
    runtime "com.h2database:h2"
    testCompile "org.grails:grails-plugin-testing"
    testCompile "org.grails.plugins:geb"
    testCompile "org.grails:grails-datastore-rest-client"
    testRuntime "org.seleniumhq.selenium:selenium-htmlunit-driver:2.47.1"
    testRuntime "net.sourceforge.htmlunit:htmlunit:2.18"

    runtime 'mysql:mysql-connector-java:5.1.36'
    compile 'org.grails.plugins:aws-sdk-s3:2.1.5'
    compile 'org.grails.plugins:spring-security-core:3.1.1'
    compile "org.grails.plugins:spring-security-rest:2.0.0.M2"

    compile 'com.nayidisha.grails.uploadr:grails3-uploadr:3.1.0'
    compile 'org.grails.plugins:joda-time:2.0.0'
    compile 'org.grails.plugins:quartz:2.0.9'
    compile 'org.grails.plugins:wkhtmltopdf:1.0.0.RC7'
    compile 'org.grails.plugins:rabbitmq:2.0.0'
    compile 'org.grails.plugins:excel-import:3.0.0.RC2'
    compile 'com.bertramlabs.plugins:selfie:1.1.1'
    compile "org.grails.plugins:swaggydoc-grails3:0.26.0"
    compile "org.grails:grails-dependencies"


}

bootRun {
    jvmArgs('-Dspring.output.ansi.enabled=always') }

grails {
    pathingJar = true }

有没有人遇到过这个问题?我该如何解决这个问题?

1 个答案:

答案 0 :(得分:3)

compile 'org.grails.plugins:spring-security-core:3.1.1'

与3.3不兼容 - 使用

compile 'org.grails.plugins:spring-security-core:3.2.0.M1'

另外,我建议使用您使用的grails版本附带的gradle包装器。 3.0已经很老了。

您可以在此处查看我的3.3.0升级说明https://gist.github.com/erichelgeson/72e1b6cb8e1b9428738799368c32133f

同样3.3.0.M2今天刚刚发布了一系列修复程序。