JPA中自動使用@Table(name = "userTab")后自動將表名、列名添加了下划線的問題


一、問題

  JPA中自動使用@Table(name = "userTab")后自動將表名、列名添加了下划線的問題,如下圖:

  

 

 二、解決

  在application.properties文件中加入:

spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

  如:

#連接字符串
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://172.16.4.203:3306/unicomcmpdb?characterEncoding=utf8&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai
spring.datasource.username=root
spring.datasource.password=123456
spring.jpa.show-sql=true
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.datasource.platform=org.hibernate.dialect.MySQL57Dialect
spring.jooq.sql-dialect=org.hibernate.dialect.MySQL57Dialect

#初始化數據
spring.datasource.schema=classpath:schema.sql
spring.datasource.data=classpath:data.sql
spring.datasource.sql-script-encoding=utf-8
spring.datasource.initialization-mode=ALWAYS
spring.datasource.continue-on-error=true
#數據表命名下划線問題
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl

 三、效果

 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM