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.
Camera.open() error -13 on emulator
Explanation of AES/CFB code part [closed]
Scanning through ArrayList for Objects with same field
Regex code in java code
Java — Objects & calling methods
Bug in OS X with JFileChooser UI (?)
What determines whether a JDialog closes when the main JFrame does?
Use webservice in Android
How to implement tablemodel in java?
Jackson parse array inside array
Java - is there a thread safe way to allocate new objects without locks?
Java deployment process
Developing and testing an OpenCV application on desktop which should later run on Android
how can I get layout like added image?
How do I pass an implemented Interface object to a method in the class its implemented in?
only the first client request arrives to the server when using java sockets