0

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!

3
  • Does this answer your question? Difference between @RestController and @RepositoryRestController Commented Dec 2, 2019 at 20:54
  • @RepositoryRestResource? I think you want @RepositoryRestController Commented Dec 2, 2019 at 20:55
  • @alan: True, I used @RepositoryRestController to annotate the controller and @RepositoryRestResource to annotate the repository. I corrected the code snippet in the question. Commented Dec 3, 2019 at 8:42

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.