I'm having an strange behaviour with the creation of spring data rest endpoints e.g. Repositories annotated with @RepositoryRestResource.
The same war file started in the same tomcat caontainer sometimes creates a endpoint, sometimes it doesn't. I've checked the Dependency tree but could not find any duplicates or version conflicts.
I have a repository class
public interface ARepository extends DefaultProjectRepository<A, Long>, JpaSpecificationExecutor<BoardnetProject> { Optional<A> findByX(String value); } And some default interface to handle authorization:
public interface DefaultProjectRepository<T, ID extends Serializable> extends JpaRepository<T, ID> { @PreAuthorize("hasAnyRole('ROLE_EDITOR,ROLE_ADMIN')") @Override <S extends T> S save(S entity); //... } And then I have a controller which should be accessible through the same path like the repository resource:
@RepositoryRestController @RequestMapping("/") public class ARepositoryController { @GetMapping("a/search/findSomeSpecial") public ResponseEntity<A> someSpecialFindMethod() { // ... } } Using @RepositoryRestResource instead of @RestController is intended here.
I also have some more casual rest controllers:
@RestController public class SimpleController { @GetMapping("/some/path/to/b") public ResponseEntity<B> getB() { //.... } } The problem now I am facing is, that sometimes the endpoints for ARepository are generated and sometimes they are not.
Someone having any idea? Thanks a lot for your time!
@RepositoryRestResource? I think you want@RepositoryRestController@RepositoryRestControllerto annotate the controller and@RepositoryRestResourceto annotate the repository. I corrected the code snippet in the question.