由于我在接口中插入了crudrepository,所以出现了这个错误:
public interface UserRepository extends CrudRepository<Utilisateur, Integer>{
public Utilisateur findUserById(int id);
}
这是我的实体
@Entity
@Table(name="utilisateur")
public class Utilisateur {
@Id
@GeneratedValue(strategy=GenerationType.AUTO)
private int id;
@NotEmpty
@Email
private String Email;
@NotEmpty
@JsonIgnore
private String Password;
private String Role;
public Utilisateur() {}
public Utilisateur(String Email, String Password){
this.Email=Email;
this.Password=Password;
}
我当然把getters和setters
和我的控制器:
@RestController
public class UserController {
@Autowired
UserRepository userRepository;
@PostMapping(value = "/User/add")
public ResponseEntity<Void> ajouterProduit(@Valid @RequestBody
Utilisateur user) {
Utilisateur userAdded = userRepository.save(user);
if (userAdded == null)
return ResponseEntity.noContent().build();
URI location = ServletUriComponentsBuilder
.fromCurrentRequest()
.path("/{id}")
.buildAndExpand(userAdded.getId())
.toUri();
return ResponseEntity.created(location).build();
}
我在openclassrooms上学习了springboot的课程,我也是这样应用的,只是我在代码中引入了Crudrepository
从堆栈跟踪中,我们可以看到,当请求pluginregistry
时,spring上下文不知道应该注入哪个bean,因为我不知道插件注册表是什么,所以我不能详细说明,但是relProviderPluginRegistry
和entityLinkspluginRegistry
是这个注入的bean候选项,spring不能决定使用哪一个。我发现这个问题是众所周知的,很少有解决办法。请参阅以下问题:
https://github.com/spring-projects/spring-hateoas/issues/1094
请注意:我不知道这些讲座有多好,但您永远不要将存储库直接暴露给API(RestController),尤其是在使用JPA+Hibernate时。存储库的功能应该隐藏在自定义API后面(@service或@component类公开存储库的功能,添加验证,限制访问等)。这通常是因为Hibernate会话使用的模型类上的可变操作也可能转换为数据库操作。应该创建facade,将存储库使用的模型类映射到facade模型类中(功能相同,但不在hibernate管理下-这里不使用@table
@entity
注释)。您将在网上找到更多关于此问题的信息。
我是Springboot的新手,我通过Sping的教程和“https://spring.io/guides”指南来学习。 现在我试图理解并重做教程:“使用MySQL访问数据” 不幸的是,我在Mavenbuild期间出错: 启动ApplicationContext时出错。要显示自动配置报告,请在启用“调试”的情况下重新运行应用程序。2017-12-07 10:26:42.708错误8100---[m
角色JAVA 任务JAVA 使用者JAVA RoleRepository.java TaskRepository。JAVA 用户库 登录注册应用程序。JAVA application.properties http://maven.apache.org/xsd/maven-4.0.0.xsd" 波姆。xml [错误]测试运行:1,失败:0,错误:1,跳过:0,耗时:2.941秒
我从以下链接下载了示例代码:https://spring.io/guides/gs/accessing-data-mysql/我更改了应用程序。属性文件如下: 之后,我转到源文件夹并运行以下命令:mvn clean spring boot:run发生此错误: 请帮我解决这个问题
配置根项目“我的应用程序”时出现问题。 未能解析配置“:classpath”的所有工件。无法解析com.android.tools.build:gradle:3.6.2。project:脱机模式下没有com.android.tools.build:gradle:3.6.2的缓存版本。脱机模式下没有com.android.tools.build:gradle:3.6.2的缓存版本。 这是我的错误,我
当我启动我的spring-boot应用程序时,我有这样的消息: com.gisapp.services.impl.userservice中的字段userDAO需要类型为“com.gisapp.gisapp.dao.IUserdao”的bean,但找不到该bean。 注入点有以下注释:-@org.springframework.beans.factory.annotation.AutoWired(r