第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

spring boot無法在mysql數(shù)據(jù)庫中生成表

spring boot無法在mysql數(shù)據(jù)庫中生成表

墨色風雨 2022-12-15 16:53:12
我正在嘗試從 defiend JpaEntities 更新數(shù)據(jù)庫模式,但 spring boot 無法生成數(shù)據(jù)庫表。日志文件:應用程序.properties 文件:spring.datasource.url= jdbc:mysql://localhost:3306/banque_dbspring.datasource.username= rootspring.datasource.password=spring.datasource.driver-class-name= com.mysql.cj.jdbc.Driverspring.jpa.hibernate.ddl-auto= updatespring.jpa.show-sql= truespring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect客戶端實體類: @Entity(name="client")public class Client implements Serializable {private static final long serialVersionUID = 1L;@Id@GeneratedValue(strategy = GenerationType.IDENTITY)private Long code;private String name;private String email;@OneToMany(mappedBy = "compte")private Collection<Compte> comptes;// + getters and setterspom.xml<?xml version="1.0" encoding="UTF-8"?>http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.0.RELEASE com.Tuto<artifactId>MaBanque</artifactId><version>0.0.1-SNAPSHOT</version><name>MaBanque</name><description>Demo project for Spring Boot</description><properties>    <java.version>1.8</java.version></properties><dependencies>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-data-jpa</artifactId>    </dependency>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-thymeleaf</artifactId>    </dependency>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-web</artifactId>    </dependency>           <dependency>        <groupId>mysql</groupId>        <artifactId>mysql-connector-java</artifactId>        <scope>runtime</scope>    </dependency>    <dependency>        <groupId>org.springframework.boot</groupId>        <artifactId>spring-boot-starter-test</artifactId>        <scope>test</scope>    </dependency>       </dependencies>
查看完整描述

3 回答

?
慕萊塢森

TA貢獻1810條經(jīng)驗 獲得超4個贊

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



查看完整回答
反對 回復 2022-12-15
?
汪汪一只貓

TA貢獻1898條經(jīng)驗 獲得超8個贊

您必須設置spring.jpa.hibernate.ddl-auto = create數(shù)據(jù)庫創(chuàng)建或create-drop

有關詳細信息,請參閱文檔。


查看完整回答
反對 回復 2022-12-15
?
翻翻過去那場雪

TA貢獻2065條經(jīng)驗 獲得超14個贊

第一個問題:application.properties文件:

  1. 如果您設置 attribute spring.jpa.hibernate.ddl-auto = update,它不會為您創(chuàng)建模式。相反,您知道,它將更新您當前沒有的現(xiàn)有數(shù)據(jù)庫。

  2. 默認spring.jpa.hibernate.ddl-auto 是create-drop,但您正在覆蓋它。

  3. 你的 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`


查看完整回答
反對 回復 2022-12-15
  • 3 回答
  • 0 關注
  • 186 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號