swagger 文件上传接口

引入pom


        
        <dependency>
            <groupId>io.springfoxgroupId>
            <artifactId>springfox-boot-starterartifactId>
        dependency>

        
        <dependency>
            <groupId>io.swaggergroupId>
            <artifactId>swagger-modelsartifactId>
        dependency>

        <dependency>
            <groupId>org.projectlombokgroupId>
            <artifactId>lombokartifactId>
        dependency>
        <dependency>
            <groupId>org.slf4jgroupId>
            <artifactId>slf4j-apiartifactId>
        dependency>


        
        <dependency>
            <groupId>org.apache.poigroupId>
            <artifactId>poi-scratchpadartifactId>
            <version>4.1.2version>
        dependency>


2.java接口

    @ApiOperation(value = "上传word文档")
    @PostMapping(value = "/upload")
    public R uploadFile(@RequestParam(value = "file") @RequestPart MultipartFile file) throws Exception
    {
        // 2007版本的word
        XWPFDocument xwpf = new XWPFDocument(file.getInputStream());    // 2007版本,仅支持docx文件处理
        List<XWPFParagraph> paragraphs = xwpf.getParagraphs();
        }

3.访问

请求路径: /swagger-ui/index.html

swagger 文件上传接口_第1张图片

你可能感兴趣的:(Java项目,java,开发语言)