问题描述:swagger文件测试接口404排查和解决,遇到这样的问题如何解决和排查我们来看。

接口测试:

这个时候怎么解决呢?看日志

1,分析问题的根源,如果是加了权限控制要放行swagger 地址,显示我们这个不是swagger没有放行,那就是鉴权出了问题。

日志鉴权貌似也没有问题?那是什么原因导致的呢?

GET http://localhost:11031/{GET%20/ydpw/collection/list}

这个地址其实很多会说是多了一个空格其实不是的,正常会转码。

那么到底是什么问题?

原因是我们的服务名称和路由的名字都是一样这样不规范,导致地址找不到我们去掉控制器的名称就好了。

 代码不规范,不摆烂了,所以代码要规范。。。

/*  *      Copyright (c) 2018-2028, Chill Zhuang All rights reserved.  *  *  Redistribution and use in source and binary forms, with or without  *  modification, are permitted provided that the following conditions are met:  *  *  Redistributions of source code must retain the above copyright notice,  *  this list of conditions and the following disclaimer.  *  Redistributions in binary form must reproduce the above copyright  *  notice, this list of conditions and the following disclaimer in the  *  documentation and/or other materials provided with the distribution.  *  Neither the name of the dreamlu.net developer nor the names of its  *  contributors may be used to endorse or promote products derived from  *  this software without specific prior written permission.  *  Author: Chill 庄骞 (smallchill@163.com)  */ package cn.citms.portal.cms.controller;  import cn.citms.example.entity.cms.TblDirectoryCollection; import cn.citms.example.vo.cms.DirectoryCollectionVo; import cn.citms.portal.cms.service.DirectoryService; import com.baomidou.mybatisplus.core.metadata.IPage; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperationSupport; import lombok.AllArgsConstructor; import org.apache.commons.lang.StringUtils; import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Query; import org.springblade.core.tool.api.R; import org.springframework.web.bind.annotation.*;  import java.util.List; import java.util.UUID;  /**  * 答案选项 控制器  *  * @author Blade  * @since 2022-02-16  */ @RestController @AllArgsConstructor @RequestMapping("/collection") @Api(value = "目录收藏", tags = "目录收藏") public class DirectoryCollectionController extends BladeController {  	private DirectoryService directoryService;  	/** 	 * 详情 	 */ 	@GetMapping("/list") 	@ApiOperationSupport(order = 1) 	@ApiOperation(value = "当前用户所有收藏", notes = "当前用户所有收藏") 	public R  detail(DirectoryCollectionVo directoryCollection) { 		List<DirectoryCollectionVo> result = directoryService.list(directoryCollection); 		return R.data(result);  	}    	 }