我使用的是hibernate和spring boot,表是在给定的数据库中创建的,而不是在另一个数据库中创建的,比如10.10.1.350是管理节点,10.10.1.348和10.10.1.349是子数据库。当我们在348中直接使用查询创建表时,然后在349中自动创建表。但我们使用的是在348中创建的hibernate then表,而不是在349中自动创建的表。
属性如:-
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://10.10.1.348:3306/test
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.username=root
spring.datasource.password=abc@1234
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect Pojo类-
@Entity
@Table(name = "test")
@Getter
@Setter
public class Test {
@Id
@Column(name = "tst_id")
private Long tstId;
@Column(name = "tst_nm")
private String tstNm;
}mysql依赖项的pom.xml -
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>发布于 2018-08-31 15:43:39
尽管Hibernate为
hibernate.hbm2ddl.auto配置属性提供了update选项,但此功能不适合生产环境。
只需使用Flyway或Liquibase进行数据库迁移。Spring boot integrates with both of them。
https://stackoverflow.com/questions/52110070
复制相似问题