Ask Your Question
1

How can the RestController's debug point be fixed in the Spring boot Test when it's not hitting?

asked 2021-12-10 11:00:00 +0000

nofretete gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-12-11 21:00:00 +0000

bukephalos gravatar image

Here are some steps that can be taken to fix the RestController's debug point in the Spring Boot Test:

  1. Make sure that the RestController is scanned and registered in the Spring Boot Application. Check if the controller is included in the @ComponentScan or @SpringBootApplication annotations.

  2. Check if the @RequestMapping annotation of the RestController is correctly mapped. The URL should match with the value specified in the annotation.

  3. Ensure that the test class is annotated with @SpringBootTest and @AutoConfigureMockMvc. This will start the Spring context and enable the MockMvc instance for testing.

  4. Verify if the request URL in the test case matches with the RestController's request mapping URL. Use the MockMvc instance to send the request to the endpoint.

  5. Check if any exceptions are thrown in the RestController code. If there are any errors or exceptions, it may not hit the debug point. Fixing the error can resolve the issue.

  6. If the RestController is still not hitting the debug point, enable the debug logs for Spring Boot. You can add logging.level.org.springframework=DEBUG in the application.properties file. This will provide detailed logs and help to troubleshoot the issue.

  7. If all the above steps fail, try using a different IDE or trying to debug in command-line mode. Sometimes, IDEs may not work well with Spring Boot Test debugging.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-12-10 11:00:00 +0000

Seen: 12 times

Last updated: Dec 11 '21