I have a spring boot (3.2.1) application that run on java 17. I also have library that contains @Entity annotations. I am connection to database using spring boot default Hibernate. I am able to connect to database, but the endpoint defined in @RestController aren't working. I was previously initializing database from the library (passing string values) and I was using EclipseLink instead of Hibernate.
I had to newly use @EntityScan to get entities from the library. Previously there was persistence.xml. For some reason I am able to connect to the database inside of the spring boot but the @RequestMapping doesn't work. I pass the connection as EntityManagerFactory to my library.
I am not using repositories, I don't know if that can have any effect on the functionality.
I was discussing problems with database connection here.
My controller look that contains the mappings looks like this:
@RestController
@RequestMapping("${com.example.apiPrefix}/data")
public class MyController extends GodController {
@Autowired
private KafkaTemplate<Integer, MyWrapper> kafkaTemplate;
@GetMapping(value = "/id", produces = {"application/json"})
@io.swagger.v3.oas.annotations.parameters.RequestBody(description = "Description...")
public ResponseEntity<MyWrapper> getId() throws DatatypeConfigurationException {
ResponseEntity<MyWrapper> res = null;
.
.
.
.
return res;
}
and the GodController looks like this:
@RequestMapping("${com.example.apiPrefix}")
@OpenAPIDefinition(
info = @Info(
title = "Hello World",
version = "1.0",
description = "Description"
)
)
public class GodController {
@Autowired
Library libr;
public SctrzController() {
}
}
So I resolved the problem. In spring boot 3 there should be http address for endpoint with backslash at the end.
I was using localhost:8080/prefix/data
It works for localhost:8080/prefix/data/
Silly mistake, hope it will help somebody one day.