spring-projects / spring-projects/spring-data-rest

@RepositoryRestController seems to not work [DATAREST-991]

Open
#1,356 6 comments 0 reactions 1 assignee View on GitHub

@odrotbohm is already working on this.

Since Dec 31, 2020.

status: feedback-provided type: bug
Dominant language
Java
Stars
958
Forks
568
PR merge metrics
No merged PRs in 30d

Description

Dimitri KOPRIWA opened DATAREST-991 and commented

It appear the repository rest controller annotation isn't working in spring-data.

Expected

to return a resource under basePath /api/greg

Result

404 Page not found

Step to reproduce

Clone project
git clone git@github.com:spring-guides/tut-react-and-spring-data-rest.git && cd tut-react-and-spring-data-rest/security
Install deps
./mvnw install
Create the file ManagerController.java under src/main/java/
@RepositoryRestController
public class ManagerController {

	@Autowired
	private ManagerRepository managerRepository;

	@Autowired
	public TestController(ManagerRepository managerRepository) {
		this.managerRepository = managerRepository;
	}

	@RequestMapping(value = "/greg")
	public ResponseEntity<Resource<Manager>> index() {
		Manager greg = this.managerRepository.findByName("greg");
		Resource<Manager> resource = new Resource<>(greg);
		return ResponseEntity.ok(resource);
	}

}
Run
./mvnw spring-boot:run
Open your browser and hit http://localhost:8080/api/greg

Version

Spring-boot 1.4.2.RELEASE

Demo

git clone git@github.com:kopax/DATAREST-991.git && cd DATAREST-991
./mvnw install
./mvnw spring-boot:run
  • Start your http client and go to http://localhost:8080 [OK]
  • Login using greg:turnquist [OK]
  • You should reach the rest api under it's base path http://localhost:8080/api [OK]
  • You should reach the rest api and get greg manager entity http://localhost:8080/api [FAIL]

The project is a clone of the security directory of this repository https://github.com/spring-guides/tut-react-and-spring-data-rest

The only file I've created is ManagerController.java https://github.com/kopax/DATAREST-991/blob/master/src/main/java/com/greglturnquist/payroll/ManagerController.java


Affects: 2.6 GA (Ingalls), 2.5.7 (Hopper SR7)

2 votes, 4 watchers

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.