Spring data repository works without annotations

前端 未结 3 1307
花落未央
花落未央 2020-12-03 22:58

I\'m using Spring Data JPA repositories (like MyRepo extends JpaRepository) and it works without @Repository and without @EnableJpaRepositori

3条回答
  •  醉梦人生
    2020-12-03 23:13

    Probably you are using Spring Boot.

    Spring Data repositories usually extend from the Repository or CrudRepository interfaces. If you are using auto-configuration, repositories will be searched from the package containing your main configuration class (the one annotated with @EnableAutoConfiguration or @SpringBootApplication) down.

    Please check https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-sql.html#boot-features-spring-data-jpa-repositories for more details.

提交回复
热议问题