之前那个问题解决了之后,又遇到了这个问题,真是多灾多难啊...
心塞
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2018-07-11 22:41:42.596 ERROR 8656 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: Invocation of init method failed; nested exception is org.hibernate.AnnotationException: No identifier specified for entity: com.server.bean.Girl
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1708)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:581)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:503)
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:317)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
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.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1089)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:859)
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)
再仔细对比下,之前写的代码,发现,导包导错了....

import org.springframework.data.annotation.Id;正确的应该是:
import javax.persistence.Id;改正之后,SpringBoot 连接MySQL 彻底没问题了......
代码,明天完善之后,在提交吧...
整理整理该睡觉了....

本文记录了在使用SpringBoot连接MySQL过程中遇到的错误及解决方法。主要问题是由于实体类中ID注解使用错误导致的,通过将Spring Data JPA的@Id更改为javax.persistence.Id,成功解决了问题。
1802

被折叠的 条评论
为什么被折叠?



