Spring JPA Error
I am getting a error like this ->
When i am trying toCan anyone help
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shelfBookController': Unsatisfied dependency expressed through field 'repository': Error creating bean with name 'userRepository' defined in com.ShelfSpace.ShelfSpace.repository.UserRepository defined in @EnableJpaRepositories declared on ShelfSpaceApplication: Not a managed type: class com.ShelfSpace.ShelfSpace.model.UserDto
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:787) ~[spring-beans-6.1.10.jar:6.1.10]org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'shelfBookController': Unsatisfied dependency expressed through field 'repository': Error creating bean with name 'userRepository' defined in com.ShelfSpace.ShelfSpace.repository.UserRepository defined in @EnableJpaRepositories declared on ShelfSpaceApplication: Not a managed type: class com.ShelfSpace.ShelfSpace.model.UserDto
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:787) ~[spring-beans-6.1.10.jar:6.1.10]When i am trying to
@GetMapping("/register")
public String registerPage(Model model) {
model.addAttribute("user", new UserDto());
return "registration"; // This corresponds to registration.html in templates folder
}
@PostMapping("/registrationPage")
public String registerUser(@ModelAttribute("user") UserDto dto) {
UserDetails details = User.builder().username(dto.getName()).
password(new BCryptPasswordEncoder()
.encode(dto.getPassword()))
.roles("ROLE_USER").build();
repository.saveUser(details);
return "success"; // This corresponds to success.html in templates folder (if you have one)
} @GetMapping("/register")
public String registerPage(Model model) {
model.addAttribute("user", new UserDto());
return "registration"; // This corresponds to registration.html in templates folder
}
@PostMapping("/registrationPage")
public String registerUser(@ModelAttribute("user") UserDto dto) {
UserDetails details = User.builder().username(dto.getName()).
password(new BCryptPasswordEncoder()
.encode(dto.getPassword()))
.roles("ROLE_USER").build();
repository.saveUser(details);
return "success"; // This corresponds to success.html in templates folder (if you have one)
}