我正在使用Spring Boot进行Spring REST。我开始将值硬编码到DAOService,如下所示,一切正常@Componentpublic class UserDAOService { static List<User> users = new ArrayList<>(); static int userCount = 3; static { users.add(new User("adam", new Date(), 1)); users.add(new User("eve", new Date(), 2)); users.add(new User("joe", new Date(), 3)); } public User saveUser(User user) { if (user.getId() == null) { user.setId(++userCount); } users.add(user); return user; } public List<User> findAll() { System.out.println("finding all users"); return users; } public User findOne(int id) { for (User user : users) { if (user.getId() == id) { return user; } } return null; }但是后来我尝试集成JPA并将bean转换为实体,如下所示,起初我在创建名称为'documentationpluginsbootstrapper'的bean时遇到了错误,但是通过从SwaggerConfig类中删除@Configuration批注解决了,但是后来又出现了另一个异常错误创建名称为'repositorySearchController'的bean。末尾显示日志 @ApiModel(description="all details about user") @Entity public class User { @Id @GeneratedValue private Integer id ; @Size(min=2,max=12,message="username should be atleast 2 characters") private String name; @Past private Date birthDate; public User(String name, Date birthDate, Integer id) { super(); this.name = name; this.birthDate = birthDate; this.id = id; } public User() { // TODO Auto-generated constructor stub } //setters and getters }日志:org.springframework.beans.factory.UnsatisfiedDependencyException:在名称为“ repositorySearchController”的bean中创建错误,该类在...... spring- data-rest-webmvc-3.0.8.RELEASE.jar中定义需要输入来解决此问题。
添加回答
举报
0/150
提交
取消