JpaRepository findAll()方法返回空结果。我正在尝试通过使用Spring-boot,h2数据库和jpa来实现rest服务。
这是我的 schema.sql
CREATE TABLE IF NOT EXISTS `City` (
`city_id` bigint(20) NOT NULL auto_increment,
`city_name` varchar(200) NOT NULL,
PRIMARY KEY (`city_id`));
Run Code Online (Sandbox Code Playgroud)
我的data.sql文件包括:
INSERT INTO City (city_id,city_name) VALUES(1,'EDE');
INSERT INTO City (city_id,city_name) VALUES(2,'DRUTEN');
INSERT INTO City (city_id,city_name) VALUES(3,'DELFT');
Run Code Online (Sandbox Code Playgroud)
该City实体:
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
@Entity
@Table(name = "City")
public class City {
@Id
@GeneratedValue
@Column(name = "city_id")
private Long cityId;
@Column(name = "city_name")
private String cityName;
public Long getCityId() …Run Code Online (Sandbox Code Playgroud)