Spring boot is not identifying rest repositories
I'm using spring data rest(1.3.5.RELEASE) to create a simple rest service. But the repository/JPA entities are not being recognized/registered, when my Application Config resides at a different package level. Here is my sample project structure: <source.root> - package1 - Application.java - package2 - RepositoryService.java - Model.java In this case the RepositoryService is not exposing any rest methods. Change in my project structure as below solves this problem. <source.root> - package1 - Application.java - package2 - RepositoryService.java - Model.java Is it mandatory for spring boot Application config to be present at the top level, so that it can scan the beans ?
If Application.java is main Spring Boot class, it most probably uses #SpringBootApplication annotation. This annotation is composite annotation and contains also #ComponentScan annotation under the hood. Now component scan by default scans current package and all the sub-packages. So with your first project structure, you excluded repositories from component scan. To solve it you have these options: Use project structure 1 and explicitly define packages to scan: #SpringBootApplication(scanBasePackages = "package2"). This is not type safe Use project structure 1 and and explicitly define class from package you want to scan: #SpringBootApplication(scanBasePackageClasses = RepositoryService.class). This is better option than option 1 as it is typesafe Stick with opinionated Spring Boot defaults and use project structure 2. Bear in mind, Spring Boot will be your best friend if you don't try to fight against its opinionated defaults. Only if you have really unbeatable reason.
How to render UI through JavaFX in an Eclipse RCP application?
configuration.yml has an error: * Unrecognized field at: driverClass - DROPWIZARD
Error 500 failed to retrieve in ud859 course
How to detect the mouse cursor/click in a previously recorded video/image frame
search and sort list of objects
Mergesort lines from a .txt file
Checking for in-app purchases
Android: MVP. Right way to communicaticate between components
how to exclude all modules of a dependency?
Display all images from Database (blob) on a jsp file in a table
how to avoid GC pauses?
Empty ListView doesn't appearance style
Realm Result returning null
How to use classes in android [closed]
int cant be converted into resultSet
Spring: Singleton that should be loaded initialized at startup