我对 Spring Boot 有疑问。我在资源文件夹和一个实体中有一个 Schema.sql。在第一次运行应用程序时,一切都按预期工作。但是当我更改 schema.sql 中的列名、更新我的实体、删除数据库表并重新运行应用程序时,Spring 始终创建旧的实体列名。
在我的 application.properties 中,我有以下条目:
spring.datasource.name = mydatasource
spring.datasource.url = jdbc:mysql://localhost:3306/dbname?serverTimezone=UTC&createDatabaseIfNotExist=true
spring.datasource.driver-class-name = com.mysql.cj.jdbc.Driver
spring.datasource.password = password
spring.datasource.username = username
spring.jpa.database-platform=org.hibernate.dialect.MySQL5Dialect
spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=update
security.oauth2.client.clientId= my_client
security.oauth2.resource.id= myid
security.oauth2.client.clientSecret= my_srcret
security.oauth2.client.accessTokenUri= http://localhost:8080/api/oauth/token
security.oauth2.client.userAuthorizationUri= http://localhost:8080/api/oauth/authorize
security.oauth2.resource.token-info-uri=http://localhost:8080/api/oauth/check_token
logging.level.org.springframework.web=DEBUG
我的新实体:
@Entity
@Table(name = "organizers")
public class Organizer implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
@Column(name = "id")
private Long id;
@Column(name = "commercialName")
private String commercialName;
@Column(name = "org_description")
private String description;
@Column(name = "verified")
private boolean verified;
@Column(name = "isOnline")
private boolean isOnline;
@Column(name = "org_type")
private OrganizerType type;
@Column(name = "alias")
private String alias;
@Column(name = "fone")
private String fone;
@OneToOne(fetch = FetchType.EAGER)
@JoinColumn(name = "userId")
private User user;
}
守候你守候我
万千封印
相关分类