当前位置:网站首页>Solve the problem of swagger document interface 404

Solve the problem of swagger document interface 404

2022-06-11 11:56:00 Code GuWa of nobody

Problem description :swagger Document test interface 404 Check and solve , In case of such problems, let's see how to solve and troubleshoot them .

The interface test :

How to solve this problem at this time ? Log

1, Analyze the root of the problem , If permission control is added, release swagger Address , It shows that we are not swagger No release , There is a problem with authentication .

There seems to be no problem with log authentication ? What is the cause of that ?

 

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

In fact, many people would say that there is an extra space in this address, but it is not , Transcoding is normal .

So what is the problem ?

The reason is that our service name and route name are the same, which is not standardized , As a result, the address cannot be found. Let's remove the name of the controller .

 

  The code is not standardized , No, it's rotten , So the code should be standardized ...

/*
 *      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  Zhuang Qian  ([email protected])
 */
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;

/**
 *  Answer options   controller 
 *
 * @author Blade
 * @since 2022-02-16
 */
@RestController
@AllArgsConstructor
@RequestMapping("/collection")
@Api(value = " Catalog collection ", tags = " Catalog collection ")
public class DirectoryCollectionController extends BladeController {

	private DirectoryService directoryService;

	/**
	 *  details 
	 */
	@GetMapping("/list")
	@ApiOperationSupport(order = 1)
	@ApiOperation(value = " All favorites of the current user ", notes = " All favorites of the current user ")
	public R  detail(DirectoryCollectionVo directoryCollection) {
		List<DirectoryCollectionVo> result = directoryService.list(directoryCollection);
		return R.data(result);

	}



	
}

 

原网站

版权声明
本文为[Code GuWa of nobody]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111140396702.html