我正在使用Spring启动,当我尝试运行并生成表时,我的数据库Oracle中没有任何结果。
这是我的application.properties
:
spring.main.banner-mode=off
# Set true for first time db initialization.
spring.datasource.initialize=true
#spring.datasource.url=jdbc:oracle:thin:@192.168.1.22:1521:DRUGSTORE
spring.datasource.url=jdbc:oracle:thin:@//192.168.1.22:1521/DRUGSTORE
spring.datasource.username=PHARM
spring.datasource.password=PHARM
spring.datasource.schema-password=PHARM
spring.datasource.schema-username=PHARM
spring.jpa.properties.hibernate.default_schema = PHARM
spring.datasource.driver-class-name=oracle.jdbc.driver.OracleDriver
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.generate-ddl=true
spring.jpa.show-sql=true
spring.jpa.database=oracle
spring.datasource.dbcp2.initial-size=7
spring.datasource.dbcp2.max-total=20
spring.datasource.dbcp2.pool-prepared-statements=true
spring.jpa.database-platform=org.hibernate.dialect.Oracle10gDialect
以下是一个示例实体:
import java.io.Serializable; import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
@Entity
@Table(name = "ADRESSE")
public class Adresse implements Serializable{
@Id
@GeneratedValue(strategy=GenerationType.TABLE)
@Column(name="ID_ADRESSE",length=255)
private BigDecimal idAdresse;
@Column(name="LINE_1",length=255)
private String line1;
@Column(name="LINE_2",length=255)
private String line2;
@Column(name="LINE_3",length=255)
private String line3;
@Column(name="LONGITUDE",length=255)
private Double longitude;
@Column(name="LATITUDE",length=255)
private Double latitude;
@ManyToOne(targetEntity=Ville.class)
@Basic(fetch = FetchType.LAZY)
private Ville ville;
@Column(name="CREATE_DATE",length=50)
@Temporal(TemporalType.DATE)
private Date createDate ;
@Column(name="LAST_UPDATE" ,length=50)
@Temporal(TemporalType.DATE)
private Date lastUpdate ;
public String getLine1() {
return line1;
}
public void setLine1(String line1) {
this.line1 = line1;
}
public String getLine2() {
return line2;
}
public void setLine2(String line2) {
this.line2 = line2;
}
public String getLine3() {
return line3;
}
public void setLine3(String line3) {
this.line3 = line3;
}
public Double getLongitude() {
return longitude;
}
public void setLongitude(Double longitude) {
this.longitude = longitude;
}
public Double getLatitude() {
return latitude;
}
public void setLatitude(Double latitude) {
this.latitude = latitude;
}
public Ville getVille() {
return ville;
}
public void setVille(Ville ville) {
this.ville = ville;
}
public Date getCreateDate() {
return createDate;
}
public BigDecimal getIdAdresse() {
return idAdresse;
}
public void setIdAdresse(BigDecimal idAdresse) {
this.idAdresse = idAdresse;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public Date getLastUpdate() {
return lastUpdate;
}
public void setLastUpdate(Date lastUpdate) {
this.lastUpdate = lastUpdate;
}
public Adresse(String line1, String line2, String line3, Double
longitude, Double latitude, Ville ville,Date createDate ,Date
lastUpdate) {
super();
this.line1 = line1;
this.line2 = line2;
this.line3 = line3;
this.longitude = longitude;
this.latitude = latitude;
this.ville = ville;
this.lastUpdate=lastUpdate;
this.createDate =createDate;
}
public Adresse() {
super();
}
}
答案 0 :(得分:1)
替换
spring.jpa.hibernate.ddl-auto=create-drop
带
spring.jpa.hibernate.ddl-auto=update