When I'm starting my mini project in spring boot (which mostly I generated from start.spring.io) from command line by command mvn spring-boot:run and walk to the http://localhost:8080/test/{michal} I see the 404 fail.
Beside that I can't create return statement in controller class using Response.create -> it shows:
The method create(String) is undefined for the type Response
I think this is the main problem why my app doesn't want to run properly.
This is my controller class
@RestController public class TestController
@Autowired
private TestService testService;
@RequestMapping(value = "/test/{name}", method = RequestMethod.GET)
public Response<String> /*@ResponseBody String*/ getWelcomeText(@PathVariable("name") String name ) {
return Response.create(testService.loadWelcomeText(name));
}
This is my service class
@Service public class TestService
public String loadWelcomeText(String name) {
return "Hello " + name;
}
Aucun commentaire:
Enregistrer un commentaire