一、新建SpringBoot Web
二、添加类库包
com.saas.pdf
删除掉多余的类,新建类:PdfUtil.java
package com.saas.pdf;
public class PdfUtil {
public static void Save(String filePath) {
System.out.println("保存成功!");
}
}
?三、com.saas.swaggerdemogit引用项目com.saas.pdf
打开Open Module Settings
?在ProductController调用:PdfUtil.Save("c://a.pdf");
package com.saas.swaggerdemo.controllers;
import com.saas.pdf.PdfUtil;
import com.saas.swaggerdemo.ProductDto;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
@RestController
@Api(value = "ProductController")
@RequestMapping("/products")
public class ProductController {
@ApiOperation(value = "保存产品")
@PostMapping("save")
public boolean SaveProduct(@RequestBody ProductDto productDto) {
PdfUtil.Save("c://a.pdf");
return true;
}
}
运行: