I created a simple RestController
, using Spring (not Boot).
@RestController
@RequestMapping(UserRestController.REST_URL)
public class UserRestController extends AbstractUserController {
static final String REST_URL = "/users";
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE)
public User get(int id) {
return super.get(id);
}
}
But when I invoke this method and use curl I receive:
$ curl -v http://localhost:8080/users
Trying 127.0.0.1...
TCP_NODELAY set
connect to 127.0.0.1 port 8080 failed: Connection refused
Failed to connect to localhost port 8080: Connection refused
Additionally: I push MocMvc-test and it failed with following result:
java.lang.AssertionError: Status expected:<200> but was:<404>
Expected :200
Actual :404
I run my app with:
public static void main(String[] args) {
try (ConfigurableApplicationContext appCtx = new
ClassPathXmlApplicationContext("spring/spring-app.xml")) {
System.out.println("Bean definition names: " +
Arrays.toString(appCtx.getBeanDefinitionNames()));
UserRestController userRestController =
appCtx.getBean(UserRestController.class);
System.out.println(userRestController.get(2));
}
}
In the console I see the output of System.out.println(userRestController.get(2));
So my CRUD-methods works good.