请问怎么才能让他启动时不自动建表
Comments
登录后评论
Sign In·
2.x.x 的第二位很重要,不同的版本可能完全不一样
我帮你看了下 2.2.x 的官方文档找到下面这段
9.10.2. Initialize a Database Using Hibernate
You can set spring.jpa.hibernate.ddl-auto
explicitly and the standard Hibernate property values are none
, validate
, update
, create
, and create-drop
. Spring Boot chooses a default value for you based on whether it thinks your database is embedded. It defaults to create-drop if no schema manager has been detected or none in all other cases. An embedded database is detected by looking at the Connection type. hsqldb, h2, and derby are embedded, and others are not. Be careful when switching from in-memory to a ‘real’ database that you do not make assumptions about the existence of the tables and data in the new platform. You either have to set ddl-auto explicitly or use one of the other mechanisms to initialize the database.
所以如果你是 spring boot 2.2 版本,配置 spring.jpa.hibernate.ddl-auto=none
应该就不会根据 Entity 对象自动建表了