亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

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

在 MySQL 數據庫中使用 spring boot 的問題

在 MySQL 數據庫中使用 spring boot 的問題

白豬掌柜的 2023-05-10 14:15:56
我正在嘗試制作一個連接到 MySQL 數據庫的 spring boot 項目,但一直出現錯誤java.sql.SQLSyntaxErrorException: 表 'db_todo.pg_class' 不存在db_todo 是我的數據庫的名稱。我正在使用 MySQL 8.0.17 版。感謝您提前給我的任何幫助。謝謝!這是我的 POJOpackage com.todo.service.todo;import javax.persistence.*;@Entity@Table(name = "todo")public class Todo {    @Id    @GeneratedValue(strategy= GenerationType.AUTO)    private int id;    @Column(nullable = false)    private String title;    @Column(nullable = false)    private boolean completed;    public Todo(int id, String title, boolean completed) {        this.id = id;        this.title = title;        this.completed = completed;    }    public Todo(){    }    public int getId() {        return id;    }    public String getTitle() {        return title;    }    public boolean isCompleted() {        return completed;    }    public void setId(int id) {        this.id = id;    }    public void setTitle(String title) {        this.title = title;    }    public void setCompleted(boolean completed) {        this.completed = completed;    }}這是我的 application.propertiesspring.jpa.hibernate.ddl-auto=updatespring.datasource.url=jdbc:mysql://${MYSQL_HOST:localhost}:3306/db_todo?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTCspring.datasource.username=springuserspring.datasource.password=ThePasswordspring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialectspring.jpa.show-sql=falsespring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl我意識到有些事情可能看起來是不必要的(時區等),但它們已經被添加到我以前的錯誤中,并且不確定為什么。最后這是我的 POM.xml,因為我正在使用 maven。
查看完整描述

1 回答

?
幕布斯7119047

TA貢獻1794條經驗 獲得超8個贊

請嘗試使用這些(因為您使用的是 MySql 而不是 PostgreSQL)

spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect

希望對您有所幫助 :)


查看完整回答
反對 回復 2023-05-10
  • 1 回答
  • 0 關注
  • 154 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號