SpringBoot启动报错:Caused by: java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile

SpringBoot项目启动报错:大致信息如下:

2018-02-06 16:40:39,878 ERROR SpringApplication:827 - Application startup failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1578)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
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.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1054)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:829)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.builder.SpringApplicationBuilder.run(SpringApplicationBuilder.java:134)
at com.springboot.cfx.SpringBootSampleApplication.main(SpringBootSampleApplication.java:19)
Caused by: java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile


解决方案:

去maven库中把 javassist文件夹删除,然后右击pom.xml文件,选择“run as”——》“Maven generate-source”,然后运行项目。

前后依赖包中的对比图如下:

更新前:


更新后:

SpringBoot启动报错:Caused by: java.lang.NoClassDefFoundError: javassist/bytecode/ClassFile_第1张图片

参照网址:https://stackoverflow.com/questions/33899791/spring-boot-javassist-not-found

Its a problem with maven dependencies. Go to your .m2 folder and erase de folder of javassist. Then update your maven dependencies and it's gonna work. I had the same problem, and it works to me


你可能感兴趣的:(spring,boot)