Java hibernate.hbm2ddl.import_同一目录中的文件不工作

Java hibernate.hbm2ddl.import_同一目录中的文件不工作,java,sql,database,hibernate,import,Java,Sql,Database,Hibernate,Import,我正在尝试使用hibernate.hbm2ddl.import_文件在启动webapp时运行sql脚本,但这似乎不起作用。我正在persistence.properties中使用以下内容: dataSource.driverClassName=com.mysql.jdbc.Driver dataSource.url=jdbc:mysql://localhost/rays_rentals?createDatabaseIfNotExist=true dataSource.username=root

我正在尝试使用hibernate.hbm2ddl.import_文件在启动webapp时运行sql脚本,但这似乎不起作用。我正在persistence.properties中使用以下内容:

dataSource.driverClassName=com.mysql.jdbc.Driver
dataSource.url=jdbc:mysql://localhost/rays_rentals?createDatabaseIfNotExist=true
dataSource.username=root
dataSource.password=

hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.show_sql=true
hibernate.hbm2ddl.auto=create

hibernate.hbm2ddl.import_files=bikes.sql
我的bikes.sql文件保存在与我的属性文件相同的位置。 这是我的sql文件:

INSERT INTO `bikes` (`id`, `brand`, `model`) VALUES (1, 'Giant', 'Propel Advanced 0');
这是我的自行车型号:

package com.BrightFuture.RaysRentalSystem.bikes;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Proxy;

@Entity
@Proxy(lazy = false)
@Table(name = "bikes")
public class Bike {

@Id @GeneratedValue(strategy=GenerationType.IDENTITY)
private Long id;

@OneToMany(mappedBy="bike", cascade=CascadeType.ALL)
private List<BikeRecord> bikeRecords = new ArrayList<BikeRecord>();

@Column(name="brand", nullable=false)
private String brand;

@Column(name="model", nullable=false)
private String model;
}
package com.brightfourture.RaysRentalSystem.bikes;
导入java.util.ArrayList;
导入java.util.List;
导入javax.persistence.CascadeType;
导入javax.persistence.Column;
导入javax.persistence.Entity;
导入javax.persistence.GeneratedValue;
导入javax.persistence.GenerationType;
导入javax.persistence.Id;
导入javax.persistence.OneToMany;
导入javax.persistence.Table;
导入org.hibernate.annotations.Proxy;
@实体
@代理(lazy=false)
@表(name=“bikes”)
公共级自行车{
@Id@GeneratedValue(策略=GenerationType.IDENTITY)
私人长id;
@OneToMany(mappedBy=“bike”,cascade=CascadeType.ALL)
private List bikeRecords=new ArrayList();
@列(name=“brand”,nullable=false)
自有品牌;
@列(name=“model”,nullable=false)
私有字符串模型;
}

谢谢。

请使用以下属性修改您的属性文件:
hibernate.hbm2ddl.auto=update
我解决了这个问题。我的问题都是对的。。我只是在我的JpaConfig中缺少了它的配置。请解释一下你说的“似乎不起作用”是什么意思?您真的使用了
persistence.properties
-还是
persistence.properties
?我检查了我的数据库,试图插入的值不在那里。我使用persistence.properties。很抱歉。。更新我的question@Shaun拉维尔,你查过日志了吗,没有例外,我没有例外。我还需要配置hibernate.hbm2ddl.import_文件以便使用它吗?这就是我的想法。仅创建和创建拖放。