I have develop a simple SpringBoot application with a rest end point as below,
@SpringBootApplication
@RestController
@RequestMapping(value = "/api")
public class Example {
@RequestMapping(value="/home", method = RequestMethod.GET)
HttpEntity<String> home() {
System.out.println("-----------myService invoke-----------");
return new ResponseEntity<String>(HttpStatus.OK);
}
public static void main(String[] args) throws Exception {
SpringApplication.run(Example.class, args);
}
}
Above works fine and return 200 in when i invoke the rest end point as, http://localhost:8080/api/home
But now i have move the rest end point to a different class as below,
@RestController
@RequestMapping(value = "/api")
public class MyController {
@RequestMapping(value="/home", method = RequestMethod.GET)
HttpEntity<String> home() {
System.out.println("-----------myService invoke-----------");
return new ResponseEntity<String>(HttpStatus.OK);
}
}
And the Example class looks like,
@SpringBootApplication
public class Example {
public static void main(String[] args) throws Exception {
SpringApplication.run(Example.class, args);
}
}
Now i invoke the end point i get below error,
{
"timestamp": 1446375811463,
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/api/home"
}
What am i missing here please?
MyControllerin the same package or sub-package asExample?