說明:此次學習使用了springboot框架,jpa注解映射實體類
1,No identifier specified for entity: com.tf.model.User
看到此錯誤第一反應百度谷歌。(經過一陣檢索)看到了答案
原因:pojo實體bean缺少了主鍵
於是返回項目中查看實體類
@Id @GeneratedValue(strategy= GenerationType.AUTO) private Long id;
- 1
- 2
- 3
- 4
- 5
缺少主鍵?開玩笑奧,我都有!細心的我又看了看數據表中字段設置,還是沒有任何問題!啊!天將降大任於斯人也!幸好我聰明伶俐,經過一番折騰(此處省略半天時間),終於發現了問題!
正文開始!
原因:包沒有引對(類名相同,但不同的包有同一種類)
改正前(部分):
import org.springframework.data.annotation.Id;
import org.springframework.data.annotation.Id;
- 1
- 2
- 3
改正后:
import javax.persistence.*;
- 1
沒錯,這兩個包中同時有@id,而持久話用到聲明主鍵的@ID在javax.persistence.*中,如果兩個包同時存在,正確的這個會被覆蓋(至於為什么,sorry,I don’t know)
2,Establishing SSL connection without server’s identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn’t set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to ‘false’. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.
這個是報出的一個警告!
原因:在高版本mysql中需要指定是否進行SSL連接
解決方案:配置文件中在spring.datasource.url 加入選項useSSL=false/true