休息端点没有调用?

时间:2017-09-18 06:08:32

标签: java spring rest controller swagger

我写了一个端点,假设上传excel文件并读取其内容。但令我惊讶的是,我在此端点中放置的第一个记录器不是打印。基本上,这意味着此端点没有调用。

MyController.java

@RestController
@RequestMapping(value = "/abc/xyz")
@Validated
@Api(basePath = "/abc/xyz", value = "/abc/xyz", produces = "application/json")
public class MyController extends BaseController {

   @RequestMapping(value = "/upload", method = RequestMethod.POST, consumes = { "multipart/form-data" }, produces = "application/json")
   @ApiOperation(value = "MyController.upload", notes = "Read File")
   @ApiResponses(value = { @ApiResponse(message = "OK", code = 200, response = ResponseEntity.class),
         @ApiResponse(message = "Forbidden", code = 403, response = ResponseEntity.class),
         @ApiResponse(message = "Internal Server Error", code = 500, response = ResponseEntity.class) })
   public List<XlsPojo> upload(@RequestParam("file") MultipartFile file) {
      logger.debug("### Calling Upload:"); // NOT PRINTING
      List<XlsPojo> pojos = new ArrayList<XlsPojo>();
      if (!file.isEmpty()) {
         logger.debug("### file: ");
         try {
            @SuppressWarnings("resource")
            Workbook workbook = new XSSFWorkbook(file.getInputStream());
            Sheet datatypeSheet = workbook.getSheetAt(1);
            Iterator<Row> iterator = datatypeSheet.iterator();
            while (iterator.hasNext()) {
               Row currentRow = iterator.next();
               if (currentRow.getRowNum() > 0) {
                  XlsPojo record = XlsPojo.getXlsRecords(currentRow);
                  System.out.println("### record: " + record);
                  pojos.add(record);
               }
            }
         } catch (Exception e) {
            System.out.println("Exception " + e);
         }
      }
      return pojos;
   }
}

的build.gradle

compile group: 'org.apache.poi', name:'poi-ooxml', version:'3.15'

我是否遗漏了上述代码段中的内容?

环境:

  1. Ubuntu 16.04
  2. Spring Boot
  3. Swagger用于记录REST API&#39;
  4. Gradle建立项目。

0 个答案:

没有答案