启动Spring Boot应用程序时出错

时间:2019-11-04 04:22:11

标签: spring hibernate spring-boot

我正在尝试启动我的spring boot应用程序,但是我遇到了一个问题,异常详细信息如下

{"Date":"2019-11-03T20:07:38,905","Thread":"localhost-startStop-1","Identifiers":{"Jvm-Instance":"1@af2e2eedeab7","App-Name":"application","Version":"1.0.0-n/a-n/a-n/a","Thread-Group":"main","Thread-Id":"37"},"Level":"ERROR","Logger":"org.springframework.boot.SpringApplication","Msg":"Application run failed","Exception-Message":"Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: net.sf.ehcache.Ehcache.getStatistics()Lnet/sf/ehcache/statistics/StatisticsGateway;","Stack-Trace":["at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:138)","at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:422)","at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1698)","at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579)","at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)","at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)","at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)","at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)","at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)","at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)","at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)","at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)","at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)","at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)","at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)","at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)","at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:155)","at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:135)","at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:87)","at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172)","at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)","at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)","at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)","at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)","at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)","at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)","at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1823)","at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)","at java.util.concurrent.FutureTask.run(FutureTask.java:266)","at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)","at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)","at java.lang.Thread.run(Thread.java:748)"]}
    dap-controller_1  | Nov 03, 2019 8:07:38 PM org.apache.catalina.core.ContainerBase addChildInternal
    dap-controller_1  | SEVERE: ContainerBase.addChild: start:
    dap-controller_1  | org.apache.catalina.LifecycleException: Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext[/dap-controller]]
    dap-controller_1  |     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:167)
    dap-controller_1  |     at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:752)
    dap-controller_1  |     at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:728)
    dap-controller_1  |     at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:734)
    dap-controller_1  |     at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:952)
    dap-controller_1  |     at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1823)
    dap-controller_1  |     at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    dap-controller_1  |     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    dap-controller_1  |     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    dap-controller_1  |     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java)
    dap-controller_1  |     at java.lang.Thread.run(Thread.java:748)
    dap-controller_1  | Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration': Invocation of init method failed; nested exception is java.lang.NoSuchMethodError: net.sf.ehcache.Ehcache.getStatistics()Lnet/sf/ehcache/statistics/StatisticsGateway;
    dap-controller_1  |     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:138)
    dap-controller_1  |     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:422)
    dap-controller_1  |     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1698)
    dap-controller_1  |     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:579)
    dap-controller_1  |     at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:501)
    dap-controller_1  |     at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
    dap-controller_1  |     at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:228)
    dap-controller_1  |     at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
    dap-controller_1  |     at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
    dap-controller_1  |     at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:760)
    dap-controller_1  |     at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:869)
    dap-controller_1  |     at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:550)
    dap-controller_1  |     at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:140)
    dap-controller_1  |     at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:759)
    dap-controller_1  |     at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:395)
    dap-controller_1  |     at org.springframework.boot.SpringApplication.run(SpringApplication.java:327)
    dap-controller_1  |     at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:155)
    dap-controller_1  |     at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:135)
    dap-controller_1  |     at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:87)
    dap-controller_1  |     at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:172)
    dap-controller_1  |     at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5196)
    dap-controller_1  |     at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    dap-controller_1  |     ... 10 more
    dap-controller_1  | Caused by: java.lang.NoSuchMethodError: net.sf.ehcache.Ehcache.getStatistics()Lnet/sf/ehcache/statistics/StatisticsGateway;
    dap-controller_1  |     at io.micrometer.core.instrument.binder.cache.EhCache2Metrics.<init>(EhCache2Metrics.java:36)
    dap-controller_1  |     at org.springframework.boot.actuate.metrics.cache.EhCache2CacheMeterBinderProvider.getMeterBinder(EhCache2CacheMeterBinderProvider.java:36)
    dap-controller_1  |     at org.springframework.boot.actuate.metrics.cache.EhCache2CacheMeterBinderProvider.getMeterBinder(EhCache2CacheMeterBinderProvider.java:31)
    dap-controller_1  |     at org.springframework.boot.actuate.metrics.cache.CacheMetricsRegistrar.lambda$getMeterBinder$0(CacheMetricsRegistrar.java:76)
    dap-controller_1  |     at org.springframework.boot.util.LambdaSafe$Callbacks.lambda$null$2(LambdaSafe.java:306)
    dap-controller_1  |     at org.springframework.boot.util.LambdaSafe$LambdaSafeCallback.invoke(LambdaSafe.java:162)
    dap-controller_1  |     at org.springframework.boot.util.LambdaSafe$Callbacks.lambda$invokeAnd$3(LambdaSafe.java:305)
    dap-controller_1  |     at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
    dap-controller_1  |     at java.util.Spliterators$IteratorSpliterator.tryAdvance(Spliterators.java:1812)
    dap-controller_1  |     at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
    dap-controller_1  |     at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
    dap-controller_1  |     at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
    dap-controller_1  |     at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
    dap-controller_1  |     at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
    dap-controller_1  |     at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    dap-controller_1  |     at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
    dap-controller_1  |     at org.springframework.boot.actuate.metrics.cache.CacheMetricsRegistrar.getMeterBinder(CacheMetricsRegistrar.java:78)
    dap-controller_1  |     at org.springframework.boot.actuate.metrics.cache.CacheMetricsRegistrar.bindCacheToRegistry(CacheMetricsRegistrar.java:62)
    dap-controller_1  |     at org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration.bindCacheToRegistry(CacheMetricsRegistrarConfiguration.java:79)
    dap-controller_1  |     at org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration.lambda$bindCacheManagerToRegistry$0(CacheMetricsRegistrarConfiguration.java:73)
    dap-controller_1  |     at java.lang.Iterable.forEach(Iterable.java:75)
    dap-controller_1  |     at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1080)
    dap-controller_1  |     at org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration.bindCacheManagerToRegistry(CacheMetricsRegistrarConfiguration.java:73)
    dap-controller_1  |     at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
    dap-controller_1  |     at org.springframework.boot.actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration.bindCachesToRegistry(CacheMetricsRegistrarConfiguration.java:69)
    dap-controller_1  |     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    dap-controller_1  |     at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    dap-controller_1  |     at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    dap-controller_1  |     at java.lang.reflect.Method.invoke(Method.java:498)
    dap-controller_1  |     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:365)
    dap-controller_1  |     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:308)
    dap-controller_1  |     at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:135)
    dap-controller_1  |     ... 31 more

我目前正在使用春季启动版本2.0.2.RELEASE,而且我正在使用

<dependency>
                <groupId>net.sf.ehcache</groupId>
                <artifactId>ehcache</artifactId>
                <version>2.10.4</version>
          </dependency>

但是我仍然遇到相同的错误,非常感谢任何帮助

预先感谢

2 个答案:

答案 0 :(得分:0)

当前,弹簧引导千分尺需要最低2.10.4的ehcache版本才能使方法net.sf.ehcache.Ehcache.getStatistics()起作用。因此,请验证ehcache版本是否被maven正确解析,或者将ehcache版本升级到新版本,然后重试。

答案 1 :(得分:0)

我能够自己解决此问题,即使我使用的是2.10.4版的ehcache,我也有另一个依赖关系,该版本使用的是较早版本的ehcache,正在考虑这个问题,所以我遇到了这个错误,我排除了那个特定的版本,然后我就可以启动并运行我的应用程序了。我感谢Deinum和Ananthapadmanabhan回答了我的问题