java - spring boot cannot inject the JpaRepository interface and prompts that the bean cannot be found
伊谢尔伦
伊谢尔伦 2017-06-12 09:27:23
0
2
1225

Field studentRepository in com.example.demo.StudentController required a bean of type 'com.example.demo.StudentRepository' that could not be found.

Action:

Consider defining a bean of type 'com.example.demo.StudentRepository' in your configuration.

@RestController
public class StudentController {

    @Autowired
    private StudentRepository studentRepository;

    @GetMapping(value = "/findAll")
    public List<Student> studentList(){
        return studentRepository.findAll();
    }

}

StudentRepository inherits JpaRepository, which should be the simplest example

There is only one package in total. SpringBootApplication and Controller are placed under the same package. There should be no ordering problems on the Internet.

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
黄舟

StudentRepository is not registered

巴扎黑

I solved it myself, the jpa package conflicted.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template