springboot中自动建表无法更新字段怎么解决

发布时间:2022-02-25 11:36:16 作者:iii
来源:亿速云 阅读:257

本篇内容主要讲解“springboot中自动建表无法更新字段怎么解决”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“springboot中自动建表无法更新字段怎么解决”吧!

关于自动建表,无法更新字段问题

Springboot中的配置

jpa:
    database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
    database: MYSQL
    show-sql: true
    properties:
      hibernate.id.new_generator_mappings: true
      hibernate.cache.use_second_level_cache: false
      hibernate.cache.use_query_cache: false
      hibernate.generate_statistics: false
      hibernate.hbm2ddl.auto: create # 自动生成建表语句
    hibernate:
      naming:
        physical-strategy: org.hibernate.boot.model.naming.PhysicalNamingStrategyStandardImpl # 取消驼峰式命名
hibernate.hbm2ddl.auto: create # 自动生成建表语句

除了create配置,还有以下几种

springboot jpa未自动建表问题记录

检查pom是否正确引入对应模块

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
 <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>

检查application文件配置是否存在错误

spring:
  datasource:
    url: jdbc:mysql://localhost:3306/dbdbd?useUnicode=true&characterEncoding=utf-8&useSSL=false
    username: *
    password: *
    driver-class-name: com.mysql.jdbc.Driver
  jpa:
    hibernate:
      ddl-auto: update
    database: mysql
    show-sql: true

检查过后,全都没毛病,项目正常启动,无报错,但是可视化工具 navicat 中并没有生成对应的表,百思不得其解,也黔驴技穷了。后来抱着试一试的想法,在mysql安装目录bin 下 ,命令行查看数据库表,发现对应的表其实已经建立成功,只是navicat没有显示出来。

springboot中自动建表无法更新字段怎么解决

到此,相信大家对“springboot中自动建表无法更新字段怎么解决”有了更深的了解,不妨来实际操作一番吧!这里是亿速云网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!

推荐阅读:
  1. 解决anaconda pip无法更新的方法
  2. springboot中DTO如何实现字符字段与日期字段的转换

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

springboot

上一篇:css中如何实现上下居中效果

下一篇:css中的tab-size属性怎么用

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》