Ok
Lets create a new controller
@RestController("/labradoodle")
public class LabradoodleController
{
private LabradoodleService labradoodleService;
public LabradoodleController(LabradoodleService labradoodleService)
{
this.labradoodleService = labradoodleService;
}
@GetMapping
@ResponseStatus(HttpStatus.OK)
public List<Labradoodle> getAll()
{
return labradoodleService.getAll();
}
@PostMapping("/new")
@ResponseStatus(HttpStatus.OK)
public Labradoodle addNew(Labradoodle labradoodle)
{
return labradoodleService.addLabradoodle(labradoodle);
}
}Now we need to do into the src/resources
we can delete the static and template packages they are not needed
Lets add the following config
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.datasource.url=jdbc:h2:~/liftoff;DB_CLOSE_ON_EXIT=TRUE
spring.datasource.username=sa
spring.datasource.password=
spring.datasource.platform=H2
server.port=8080
spring.datasource.driverClassName=org.h2.Driver#OK we are close
Lets go ahead and try to run this
should we running
ok lets download postman
Ok now
lets hit http://localhost:8080/labradoodle/new
(change it to raw and the text type to json)
with a post request in postman with the following JSON body
export const _frontmatter = {"title":"The Final Step! 🤪","root":"/docs","parents":["Spring-Boot"]}