当 Spring Boot 尝试在表中插入数据时,我遇到了错误。我正在使用 H2 和 Spring Boot 2.5.0。似乎 Spring 没有创建表。
这是我的实体
@Entity(name = "Users")
@Table(name = "users")
public class UserEntity implements Serializable {
// Serial
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Integer id;
private String name;
private String surname;
private String email;
// Getters and setters
}
Run Code Online (Sandbox Code Playgroud)
还有我的仓库
public interface UserRepository extends JpaRepository<UserEntity, Integer> {
}
Run Code Online (Sandbox Code Playgroud)
我已经添加到我的 pom.xmlh2
和spring-boot-starter-data-jpa
.
当我以调试模式启动服务器时,出现此错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSourceScriptDatabaseInitializer' defined in class path resource [org/springframework/boot/autoconfigure/sql/init/DataSourceInitializationConfiguration.class]: Invocation of init method …
Run Code Online (Sandbox Code Playgroud)