当前位置: 首页 > news >正文

福田网站建设推荐wordpress 图片显示慢

福田网站建设推荐,wordpress 图片显示慢,wordpress会员评论,网架加工厂有招工的吗文章目录 一、场景描述:swagger导出文件名称乱码二、乱码原因三、解决方法3.1、方法一、在浏览器中输入地址下载3.2、方法二、swagger升级为2.10.0及以上 四、可能遇到的问题4.1、DocumentationPluginsManager.java:152 一、场景描述:swagger导出文件名称…

文章目录

  • 一、场景描述:swagger导出文件名称乱码
  • 二、乱码原因
  • 三、解决方法
    • 3.1、方法一、在浏览器中输入地址下载
    • 3.2、方法二、swagger升级为2.10.0及以上
  • 四、可能遇到的问题
    • 4.1、DocumentationPluginsManager.java:152

一、场景描述:swagger导出文件名称乱码

场景描述:springboot项目集成swagger2.9.2后,下载文件时若文件名有中文则乱码。

(1)依赖如下

<!--swagger2-->
<dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.9.2</version>
</dependency>
<dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>2.9.2</version>
</dependency>

(2)下载文件乱码如下
在这里插入图片描述
(3)java代码如下

@Controller
@RequestMapping("/file")
public class FileController {@GetMapping("/export1")public void printSubmit1( HttpServletResponse response) throws Exception {//获取模板位置InputStream templateFileName = getClass().getResourceAsStream("/template/dataSourceDetailExport.xlsx");String fileName = "测试文件";List<List<String>> dataList = new ArrayList<>();for(int i=0;i<3;i++){List<String> data = new ArrayList<>();for(int j=1;j<10;j++){data.add(i+""+j);}dataList.add(data);}try {//对文件名进行编码,防止中文乱码fileName = URLEncoder.encode(fileName, "UTF-8");response.setContentType("application/vnd.ms-excel");response.setCharacterEncoding("utf8");response.setHeader("Content-Disposition", "attachment; filename=" + fileName + ".xlsx");response.setHeader("Pragma", "public");response.setHeader("Cache-Control", "no-store");response.addHeader("Cache-Control", "max-age=0");OutputStream os = response.getOutputStream();EasyExcel.write(os).withTemplate(templateFileName).sheet().doWrite(dataList);;} catch (IOException e) {throw new Exception("导出excel表格失败!", e);}}
}

二、乱码原因

这是由于sweagger2.9.2版本问题导致的,在swagger2.9.2中下载是乱码的,但是直接在浏览器中输入请求下载就是正常的。

三、解决方法

3.1、方法一、在浏览器中输入地址下载

在这里插入图片描述

3.2、方法二、swagger升级为2.10.0及以上

需要将swagger升级为2.10.0及以上
重点:需要swagger包含的spring-plugin-core包是2.0.0.RELEASE版本,swagger包含的spring-plugin-metadata包是2.0.0.RELEASE版本

(1)依赖如下

<!--swagger2-->
<dependency><groupId>io.springfox</groupId><artifactId>springfox-spring-webmvc</artifactId><version>2.10.0</version>
</dependency>
<dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger2</artifactId><version>2.10.0</version>
</dependency>
<dependency><groupId>io.springfox</groupId><artifactId>springfox-swagger-ui</artifactId><version>2.10.0</version>
</dependency>

(2)swagger配置如下

package com.demo.config;import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;import java.text.SimpleDateFormat;
import java.util.Date;@Configuration
@EnableSwagger2WebMvc
public class SwaggerConfig
{@Beanpublic Docket createRestApi() {return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().apis(RequestHandlerSelectors.basePackage("com.demo")) //你自己的package.paths(PathSelectors.any()).build();}public ApiInfo apiInfo() {return new ApiInfoBuilder().title("小工具"+"\t"+new SimpleDateFormat("yyyy-MM-dd").format(new Date())).description("docker-compose").version("1.0").termsOfServiceUrl("").build();}
}

(3)下载结果如下图
在这里插入图片描述

四、可能遇到的问题

4.1、DocumentationPluginsManager.java:152

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

springfox.documentation.spring.web.plugins.DocumentationPluginsManager.createContextBuilder(DocumentationPluginsManager.java:152)

The following method did not exist:

org.springframework.plugin.core.PluginRegistry.getPluginFor(Ljava/lang/Object;Lorg/springframework/plugin/core/Plugin;)Lorg/springframework/plugin/core/Plugin;

The method's class, org.springframework.plugin.core.PluginRegistry, is available from the following locations:

jar:file:/D:/maven/MavenRepository/org/springframework/plugin/spring-plugin-core/2.0.0.RELEASE/spring-plugin-core-2.0.0.RELEASE.jar!/org/springframework/plugin/core/PluginRegistry.class

The class hierarchy was loaded from the following locations:

org.springframework.plugin.core.PluginRegistry: file:/D:/maven/MavenRepository/org/springframework/plugin/spring-plugin-core/2.0.0.RELEASE/spring-plugin-core-2.0.0.RELEASE.jar


Action:

Correct the classpath of your application so that it contains a single, compatible version of org.springframework.plugin.core.PluginRegistry

若遇到以上问题,则先在swagger中排除以下依赖,并手动引入以下版本的依赖

<dependency><artifactId>spring-plugin-core</artifactId><groupId>org.springframework.plugin</groupId><version>2.0.0.RELEASE</version>
</dependency>
<dependency><artifactId>spring-plugin-metadata</artifactId><groupId>org.springframework.plugin</groupId><version>2.0.0.RELEASE</version>
</dependency>

注意: spring-plugin-core-2.0.0.RELEASE版本需要与swagger2.10.0及以上版本配合使用。若swagger版本为2.9.2及以下,需要用低版本的spring-plugin-core-1.2.0.RELEASE版本

http://www.yayakq.cn/news/213410/

相关文章:

  • 阜宁网站制作价格安康优质网站建设方案
  • wordpress建站环境搭建站长之家seo查找
  • 重庆建设教育协会网站首页石家庄网页设计制作
  • 地方门户网站运营方案国外搜索引擎网站
  • 源码怎样做网站如何做图片网站
  • 协达网站建设网页游戏折扣平台
  • 网站建设费归入长期待摊费用cuteftp 备份网站
  • 怎么给网站制作二维码广州网页制作公司排名
  • 学生组织网站建设wordpress 排除分类
  • 公司网站建设教程建设网站毕业设计开题报告
  • 汉中网站建设有限公司如何做自己官方网站
  • 包头建设工程安全监督站网站免费建网站的网站
  • 如何开网站赚钱免费私人网站
  • 医院网站 行风建设辽宁建设工程信息网上开标流程
  • 只有一个域名怎么做网站中国建设人才网信息网站
  • 学网站建设与管理难吗虚拟主机网站建设步骤
  • 成都游戏网站建设专做健身餐的网站
  • 上海市建设执业注册中心网站上海关键词推广公司
  • 网站建设企业邮箱制作网站网站推广工具推荐
  • 手机网站开发库做网站 难
  • 撤销网站备案wordpress主题搜索引擎
  • 网站维护托管要多少钱高新苏州网站建设
  • 建设银行安徽 招聘网站国内大型游戏外包公司
  • jsp网站连接数据库河北省做网站哪家公司好
  • 网站怎么盈利做平台推广怎么找客户
  • 山东济南网站建设找工程包工平台
  • html5 微网站阿里云服务器wordpress建站教程
  • 大连网站快速排名提升网站建设公司会议网站
  • 多用户分布式网站开发百度搜索引擎优化的推广计划
  • 鞋材 技术支持 东莞网站建设wordpress加表单