连接到127.0.0.1端口8080失败:连接被拒绝

我使用Spring(而非Boot)创建了一个简单的Rest Controller。

@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);
  }
}

但是,当我调用此方法并使用curl时,我收到:

$ 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
评论