Java Spring MVC控制器死机且没有响应

Java Spring MVC控制器死机且没有响应,java,spring,spring-mvc,Java,Spring,Spring Mvc,我面临一些具体问题: 我的rest控制器工作了几个小时,当我向它发出请求时,我不知道为什么。它没有回应。浏览器中的加载过程正在等待响应一段时间。若我用海报发送请求,我可以看到请求被发送到控制器,但并没有收到响应。我试图调试应用程序,我有一些预定的处理-他们正在工作。但不是。请求未到达控制器。它以前卡住了。我怎样才能知道这是在哪里发生的?非常感谢。这是我的控制器类: @RestController @RequestMapping("/quotes") public class QuotesCont

我面临一些具体问题: 我的rest控制器工作了几个小时,当我向它发出请求时,我不知道为什么。它没有回应。浏览器中的加载过程正在等待响应一段时间。若我用海报发送请求,我可以看到请求被发送到控制器,但并没有收到响应。我试图调试应用程序,我有一些预定的处理-他们正在工作。但不是。请求未到达控制器。它以前卡住了。我怎样才能知道这是在哪里发生的?非常感谢。这是我的控制器类:

@RestController
@RequestMapping("/quotes")
public class QuotesController {

private final QuotesService quotesService;

@Autowired
public QuotesController(QuotesService quotesService) {
    this.quotesService = quotesService;
}

@RequestMapping(value="", method= RequestMethod.GET, produces = "application/json; charset=utf-8")
public ResponseEntity<List<LoadedFileInfo>> getLoadedFilesData(){
    List<LoadedFileInfo> result = quotesService.getLoadedFilesData();
    return new ResponseEntity<List<LoadedFileInfo>>(result, HttpStatus.OK);
}

@RequestMapping(value="/currencyPairs", method= RequestMethod.GET, produces = "application/json; charset=utf-8")
public ResponseEntity<List<CurrencyPair>> getCurrencyPairs(){
    return new ResponseEntity<List<CurrencyPair>>(quotesService.getCurrencyPairs(), HttpStatus.OK);
}

@RequestMapping(value="/oneMinute", method= RequestMethod.GET, produces = "application/json; charset=utf-8")
public ResponseEntity<List<Number[]>> getOneMinuteQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){
    return new ResponseEntity<List<Number[]>>(quotesService.getOneMinuteQuotes(from, to, currencyPair), HttpStatus.OK);
}

@RequestMapping(value="/fiveMinutes", method= RequestMethod.GET, produces = "application/json; charset=utf-8")
public ResponseEntity<List<Number[]>> getFiveMinutesQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){
    return new ResponseEntity<List<Number[]>>(quotesService.getFiveMinuteQuotes(from, to, currencyPair), HttpStatus.OK);
}

@RequestMapping(value="/fifteenMinutes", method= RequestMethod.GET, produces = "application/json; charset=utf-8")
public ResponseEntity<List<Number[]>> getFifteenMinutesQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){
    return new ResponseEntity<List<Number[]>>(quotesService.getFifteenMinuteQuotes(from, to, currencyPair), HttpStatus.OK);
}

@RequestMapping(value="/thirtyMinutes", method= RequestMethod.GET, produces = "application/json; charset=utf-8")
public ResponseEntity<List<Number[]>> getThirtyMinutesQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){
    return new ResponseEntity<List<Number[]>>(quotesService.getThirtyMinuteQuotes(from, to, currencyPair), HttpStatus.OK);
}

@RequestMapping(value="/oneHour", method= RequestMethod.GET, produces = "application/json; charset=utf-8")
public ResponseEntity<List<Number[]>> getOneHourQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){
    return new ResponseEntity<List<Number[]>>(quotesService.getOneHourQuotes(from, to, currencyPair), HttpStatus.OK);
}

@RequestMapping(value="/fourHours", method= RequestMethod.GET, produces = "application/json; charset=utf-8")
public ResponseEntity<List<Number[]>> getFourHourQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){
    return new ResponseEntity<List<Number[]>>(quotesService.getFourHourQuotes(from, to, currencyPair), HttpStatus.OK);
}

@RequestMapping(value="/oneDay", method= RequestMethod.GET, produces = "application/json; charset=utf-8")
public ResponseEntity<List<Number[]>> getOneDayQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){
    return new ResponseEntity<List<Number[]>>(quotesService.getOneDayQuotes(from, to, currencyPair), HttpStatus.OK);
}

@RequestMapping(value="/oneWeek", method= RequestMethod.GET, produces = "application/json; charset=utf-8")
public ResponseEntity<List<Number[]>> getOneWeekQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){
    return new ResponseEntity<List<Number[]>>(quotesService.getOneWeekQuotes(from, to, currencyPair), HttpStatus.OK);
}

@RequestMapping(value="/oneMonth", method= RequestMethod.GET, produces = "application/json; charset=utf-8")
public ResponseEntity<List<Number[]>> getOneMonthQuotes(@RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime from, @RequestParam @DateTimeFormat(iso= DateTimeFormat.ISO.DATE_TIME) LocalDateTime to, @RequestParam Integer currencyPair){
    return new ResponseEntity<List<Number[]>>(quotesService.getOneMonthQuotes(from, to, currencyPair), HttpStatus.OK);
}
@RestController
@请求映射(“/quotes”)
公共类报价控制器{
私人最终报价服务报价服务;
@自动连线
公共报价控制器(报价服务报价服务){
this.quoteService=quoteService;
}
@RequestMapping(value=”“,method=RequestMethod.GET,products=“应用程序/json;字符集=utf-8”)
公共响应属性getLoadedFilesData(){
List result=quoteService.getLoadedFileData();
返回新的响应状态(结果,HttpStatus.OK);
}
@RequestMapping(value=“/currencyPairs”,method=RequestMethod.GET,products=“application/json;charset=utf-8”)
公共响应getCurrencyPairs(){
返回新的ResponseEntity(QuoteService.getCurrencyPairs(),HttpStatus.OK);
}
@RequestMapping(value=“/oneMinute”,method=RequestMethod.GET,products=“application/json;charset=utf-8”)
公共响应getOneMinuteQuotes(@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime from,@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime to,@RequestParam Integer currencyPair){
返回新的ResponseEntity(QuoteService.getOneMinuteQuotes(from,to,currencyPair),HttpStatus.OK);
}
@RequestMapping(value=“/fiveMinutes”,method=RequestMethod.GET,products=“application/json;charset=utf-8”)
公共响应getFiveMinutesQuotes(@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime from,@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime to,@RequestParam Integer currencyPair){
返回新的ResponseEntity(QuoteService.getFiveMinuteQuotes(from,to,currencyPair),HttpStatus.OK);
}
@RequestMapping(value=“/fifteenMinutes”,method=RequestMethod.GET,products=“application/json;charset=utf-8”)
公共响应getFifteenMinutesQuotes(@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime从,@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime到,@RequestParam Integer currencyPair){
返回新的ResponseEntity(QuoteService.getFifteenMinuteQuotes(from,to,currencyPair),HttpStatus.OK);
}
@RequestMapping(value=“/thirtyMinutes”,method=RequestMethod.GET,products=“application/json;charset=utf-8”)
公共响应getThirtyMinutesQuotes(@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime from,@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime to,@RequestParam Integer currencyPair){
返回新的ResponseEntity(QuoteService.getThirtiminuteQuotes(from,to,currencyPair),HttpStatus.OK);
}
@RequestMapping(value=“/oneHour”,method=RequestMethod.GET,products=“application/json;charset=utf-8”)
公共响应性getOneHourQuotes(@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime from,@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime to,@RequestParam Integer currencyPair){
返回新的ResponseEntity(quotesService.getOneHourQuotes(from,to,currencyPair),HttpStatus.OK);
}
@RequestMapping(value=“/fourHours”,method=RequestMethod.GET,products=“application/json;charset=utf-8”)
公共响应getFourHourQuotes(@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime from,@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime to,@RequestParam Integer currencyPair){
返回新的ResponseEntity(QuoteService.getFourHourQuotes(from,to,currencyPair),HttpStatus.OK);
}
@RequestMapping(value=“/oneDay”,method=RequestMethod.GET,products=“application/json;charset=utf-8”)
public ResponseEntity getOneDayQuotes(@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime from,@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime to,@RequestParam Integer currencyPair){
返回新的ResponseEntity(quoteService.getOneDayQuotes(from,to,currencyPair),HttpStatus.OK);
}
@RequestMapping(value=“/oneWeek”,method=RequestMethod.GET,products=“application/json;charset=utf-8”)
公共响应性getOneWeekQuotes(@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime from,@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime to,@RequestParam Integer currencyPair){
返回新的ResponseEntity(quotesService.getOneWeekQuotes(from,to,currencyPair),HttpStatus.OK);
}
@RequestMapping(value=“/oneMonth”,method=RequestMethod.GET,products=“application/json;charset=utf-8”)
公共响应getOneMonthQuotes(@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime from,@RequestParam@DateTimeFormat(iso=DateTimeFormat.iso.DATE\u TIME)LocalDateTime to,@RequestParam Integer currencyPair){
返回新的ResponseEntity(quotesService.getOneMonthQuotes(from,to,currencyPair),HttpStatus.OK);
}

}

我不认为您的控制器有问题,至少在提供的代码中没有证据表明这一点。 这里出现问题的原因有很多,举几个例子:

  • HTTP连接池已满 运行您的应用程序的web服务器有一个连接池—许多可用的HTTP连接。 除非您使用的是异步的东西(我想您不会),否则池中可能会出现大量正在运行的连接