mirror of
https://github.com/RemainderTime/spring-boot-base-demo.git
synced 2026-02-23 06:30:46 +08:00
Dockerfile 配置为coding构建
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package cn.xf.basedemo.config;
|
||||
|
||||
import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.web.CorsEndpointProperties;
|
||||
import org.springframework.boot.actuate.autoconfigure.endpoint.web.WebEndpointProperties;
|
||||
import org.springframework.boot.actuate.autoconfigure.web.server.ManagementPortType;
|
||||
@@ -12,15 +13,17 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import springfox.documentation.builders.ApiInfoBuilder;
|
||||
import springfox.documentation.builders.ParameterBuilder;
|
||||
import springfox.documentation.builders.PathSelectors;
|
||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
||||
import springfox.documentation.oas.annotations.EnableOpenApi;
|
||||
import springfox.documentation.schema.ModelRef;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.service.Contact;
|
||||
import springfox.documentation.service.Parameter;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
import springfox.documentation.spring.web.plugins.Docket;
|
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -33,41 +36,30 @@ import java.util.List;
|
||||
* @author: xiongfeng
|
||||
* @create: 2022-06-16 16:44
|
||||
**/
|
||||
@EnableOpenApi
|
||||
@Configuration
|
||||
@EnableKnife4j
|
||||
public class SpringFoxSwaggerConfig {
|
||||
|
||||
/**
|
||||
* 配置基本信息
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public ApiInfo apiInfo() {
|
||||
return new ApiInfoBuilder()
|
||||
.title("Swagger Test App Restful API")
|
||||
.description("swagger test app restful api")
|
||||
.termsOfServiceUrl("https://github.com/RemainderTime")
|
||||
.contact(new Contact("君燕尾","https://blog.csdn.net/qq_39818325","fairy_xingyun@hotmail.com"))
|
||||
.version("1.0")
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置文档生成最佳实践
|
||||
* @param apiInfo
|
||||
* @return
|
||||
*/
|
||||
@Bean
|
||||
public Docket createRestApi(ApiInfo apiInfo) {
|
||||
return new Docket(DocumentationType.OAS_30)
|
||||
.apiInfo(apiInfo)
|
||||
.groupName("SwaggerGroupOneAPI")
|
||||
public Docket createRestApi() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.apiInfo(apiInfo())
|
||||
.select()
|
||||
.apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
|
||||
.apis(RequestHandlerSelectors.basePackage("com.didiplus"))
|
||||
.paths(PathSelectors.any())
|
||||
.build();
|
||||
}
|
||||
private ApiInfo apiInfo() {
|
||||
Contact contact =new Contact("","","");
|
||||
return new ApiInfoBuilder()
|
||||
.title("SpringBoot项目 后台服务API接口文档")
|
||||
.description("使用 knife4j 搭建的后台服务API接口文档")
|
||||
.termsOfServiceUrl("http://localhost:8088/")
|
||||
.contact(contact)
|
||||
.version("1.0.0")
|
||||
.build();
|
||||
|
||||
}
|
||||
/**
|
||||
* 增加如下配置可解决Spring Boot 6.x 与Swagger 3.0.0 不兼容问题
|
||||
**/
|
||||
|
||||
@@ -6,6 +6,7 @@ import cn.xf.basedemo.interceptor.SessionContext;
|
||||
import cn.xf.basedemo.model.res.LoginInfoRes;
|
||||
import cn.xf.basedemo.service.UserService;
|
||||
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -20,7 +21,8 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
* @author: xiongfeng
|
||||
* @create: 2022-06-28 09:17
|
||||
**/
|
||||
@RestController
|
||||
@Api(tags = "用户控制器")
|
||||
@RestController(value = "用户控制器")
|
||||
@RequestMapping("/user")
|
||||
public class UserController {
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
**/
|
||||
@Controller
|
||||
@RequestMapping("web")
|
||||
public class LoginController {
|
||||
public class WebController {
|
||||
|
||||
/**
|
||||
* @Description 进入登录页面
|
||||
@@ -3,6 +3,7 @@ package cn.xf.basedemo.interceptor;
|
||||
import cn.xf.basedemo.interceptor.TokenInterceptor;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
|
||||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
|
||||
|
||||
/**
|
||||
@@ -21,4 +22,16 @@ public class InterceptorConfig implements WebMvcConfigurer {
|
||||
.addPathPatterns("/**") //需要拦截的请求(设置的全部拦截)
|
||||
.excludePathPatterns("/user/login","/web/**"); //忽略的请求
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 放行Knife4j请求
|
||||
* @param registry
|
||||
*/
|
||||
@Override
|
||||
public void addResourceHandlers(ResourceHandlerRegistry registry) {
|
||||
registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
|
||||
registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user