I am having some spring boot rest tutorial. I fail to reach the controller method when I call:
http://localhost:8090/customers/stam
Tomcat log:
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8090 (http) with context path ''
t.s.SpringbootRestDemoApplication : Started SpringbootRestDemoApplication in 2.696 seconds (JVM running for 4.042)
The response I get:
{
"timestamp": "2019-06-02T12:25:03.400+0000",
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/customers/stam"
}
Can you assist?
package ttt.springboot_rest_demo;
import ...
@SpringBootApplication
@ComponentScan({"springboot_rest_demo.controller", "springboot_rest_demo.data"})
public class SpringbootRestDemoApplication {
public static void main(String[] args) {
SpringApplication.run(SpringbootRestDemoApplication.class, args);
}
}
package ttt.springboot_rest_demo.controller;
import ...
@RestController
@RequestMapping("/customers")
public class CustomerController {
@RequestMapping(value = "/stam", method = RequestMethod.GET)
public ResponseEntity < Customer > getCustomer() {
return new ResponseEntity < >(new Customer(), HttpStatus.OK);
}
}
package ttt.springboot_rest_demo.data;
public class Customer {
private String name;
private int age;
private String email;
private Long id;
//getters and setters
}
This is only a part of the project. I use also a service class but because I have failed, I a added a simple controller method which doesn't need the service class for now, just to ease the example.
