【发布时间】:2021-02-21 00:35:23
【问题描述】:
无法理解以下错误:
Entity:
package com.example.demo.entity;
import javax.persistence.Entity;
import javax.persistence.Table;
@Entity
@Table(name="lecture")
public class EntityP1 {
private Long id;
private String name;
private String last;
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getLast() {
return last;
}
public void setLast(String last) {
this.last = last;
}
}
Repository:
package com.example.demo.repo;
import org.springframework.data.repository.CrudRepository;
import org.springframework.stereotype.Repository;
import com.example.demo.entity.EntityP1;
public interface RepoP1 extends CrudRepository<EntityP1, Long> {
}
错误:
启动 ApplicationContext 时出错。要显示条件报告,请在启用“调试”的情况下重新运行您的应用程序。 2020-11-09 09:25:24.133 错误 11904 --- [main] os.boot.SpringApplication:应用程序运行失败
org.springframework.beans.factory.UnsatisfiedDependencyException:在 URL [jar:file:/Users/umair/.m2/repository/org/springframework/data/spring-data-rest 中定义名称为“repositorySearchController”的 bean 创建错误-webmvc/3.3.5.RELEASE/spring-data-rest-webmvc-3.3.5.RELEASE.jar!/org/springframework/data/rest/webmvc/RepositorySearchController.class]:通过构造函数参数0表示的不满足的依赖关系;嵌套异常是 org.springframework.beans.factory.BeanCreationException:在类路径资源 [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class] 中定义名称为“pagedResourcesAssembler”的 bean 创建时出错:通过工厂方法进行 Bean 实例化失败;嵌套异常是 org.springframework.beans.BeanInstantiationException:无法实例化 [org.springframework.data.web.PagedResourcesAssembler]:工厂方法“pagedResourcesAssembler”抛出异常;嵌套异常是 org.springframework.beans.factory.BeanCreationException: Error created bean with name 'pageableResolver' defined in class path resource.......
【问题讨论】:
-
没有为您的实体定义主键。像这样注释
id字段@Id @GeneratedValue(strategy = GenerationType.IDENTITY)
标签: java spring spring-boot