NoClassDefFoundError 问题
错误日志:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name "emailTemplateResolver" defined in class path resource [com/qdum/darphin/config/ThymeleafConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.templateresolver.ClassLoaderTemplateResolver]: Factory method "emailTemplateResolver" threw exception; nested exception is java.lang.NoClassDefFoundError: org/thymeleaf/util/ResourcePool
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1173)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:513)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:483)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:761)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:866)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:542)
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 com.qdum.darphin.system.DarphinApp.main(DarphinApp.java:70)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.templateresolver.ClassLoaderTemplateResolver]: Factory method "emailTemplateResolver" threw exception; nested exception is java.lang.NoClassDefFoundError: org/thymeleaf/util/ResourcePool
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 21 common frames omitted
Caused by: java.lang.NoClassDefFoundError: org/thymeleaf/util/ResourcePool
at org.thymeleaf.templateparser.xmlsax.AbstractNonValidatingSAXTemplateParser.createSaxParsers(AbstractNonValidatingSAXTemplateParser.java:109)
at org.thymeleaf.templateparser.xmlsax.AbstractNonValidatingSAXTemplateParser.<init>(AbstractNonValidatingSAXTemplateParser.java:89)
at org.thymeleaf.templateparser.xmlsax.XmlNonValidatingSAXTemplateParser.<init>(XmlNonValidatingSAXTemplateParser.java:55)
at org.thymeleaf.templatemode.StandardTemplateModeHandlers.<clinit>(StandardTemplateModeHandlers.java:83)
at org.thymeleaf.templateresolver.TemplateResolver.<clinit>(TemplateResolver.java:68)
at com.qdum.darphin.config.ThymeleafConfiguration.emailTemplateResolver(ThymeleafConfiguration.java:18)
at com.qdum.darphin.config.ThymeleafConfiguration$$EnhancerBySpringCGLIB$$3c03705d.CGLIB$emailTemplateResolver$0(<generated>)
at com.qdum.darphin.config.ThymeleafConfiguration$$EnhancerBySpringCGLIB$$3c03705d$$FastClassBySpringCGLIB$$5eb6a5ff.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:356)
at com.qdum.darphin.config.ThymeleafConfiguration$$EnhancerBySpringCGLIB$$3c03705d.emailTemplateResolver(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 22 common frames omitted
Caused by: java.lang.ClassNotFoundException: org.thymeleaf.util.ResourcePool
at java.net.URLClassLoader$1.run(URLClassLoader.java:370)
at java.net.URLClassLoader$1.run(URLClassLoader.java:362)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:361)
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)
... 38 common frames omitted
Caused by: java.util.zip.ZipException: invalid LOC header (bad signature)
at java.util.zip.ZipFile.read(Native Method)
at java.util.zip.ZipFile.access$1400(ZipFile.java:60)
at java.util.zip.ZipFile$ZipFileInputStream.read(ZipFile.java:717)
at java.util.zip.ZipFile$ZipFileInflaterInputStream.fill(ZipFile.java:419)
at java.util.zip.InflaterInputStream.read(InflaterInputStream.java:158)
at sun.misc.Resource.getBytes(Resource.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:462)
at java.net.URLClassLoader.access$100(URLClassLoader.java:73)
at java.net.URLClassLoader$1.run(URLClassLoader.java:368)
... 44 common frames omitted
关键词:”emailTemplateResolver” threw exception; nested exception is java.lang.NoClassDefFoundError: org/thymeleaf/util/ResourcePool
解决思路:删除.m2中的相应文件, 然后重新加载pom文件。
其他内容:COMMAND + O可以查找类、文件等。