3 回答

TA貢獻1810條經(jīng)驗 獲得超4個贊
實際上,問題是實體類不在正確的包中。包含主類和 org.entities 的 org.example 由于某種原因 spring boot 沒有生成表,所以當我移動實體包使其變得像 org.example.entities 并運行應用程序時,所有的表都成功生成了。謝謝你們的幫助我很感激:)

TA貢獻2065條經(jīng)驗 獲得超14個贊
第一個問題:application.properties
文件:
如果您設置 attribute
spring.jpa.hibernate.ddl-auto = update
,它不會為您創(chuàng)建模式。相反,您知道,它將更新您當前沒有的現(xiàn)有數(shù)據(jù)庫。的默認值
spring.jpa.hibernate.ddl-auto
是create-drop
,但您正在覆蓋它。你的 application.properties必須在
源代碼/主要/資源
文件夾。
==> 你應該修復:
spring.jpa.hibernate.ddl-auto = 創(chuàng)建 - 刪除
第二個問題:實體類。您應該在屬性之上添加@Column ,如下所示:
`@Entity(name="client")
public class Client implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Column
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long code;
@Column
private String name;
@Column
private String email;
@OneToMany(mappedBy = "compte")
private Collection<Compte> comptes;
// + getters and setters`
添加回答
舉報