diff --git a/.gitignore b/.gitignore index 5dfe643..0d35399 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,7 @@ *.gitignore */target/ *.imi -*.DS_Store \ No newline at end of file +*.DS_Store + +logs +*.log \ No newline at end of file diff --git a/dc-admin/pom.xml b/dc-admin/pom.xml index 151104c..0a1a30e 100644 --- a/dc-admin/pom.xml +++ b/dc-admin/pom.xml @@ -24,12 +24,6 @@ true - - - io.springfox - springfox-boot-starter - - mysql diff --git a/dc-admin/src/main/java/com/dc/web/DcApplication.java b/dc-admin/src/main/java/com/dc/web/DcApplication.java index 64b88e9..327aee4 100644 --- a/dc-admin/src/main/java/com/dc/web/DcApplication.java +++ b/dc-admin/src/main/java/com/dc/web/DcApplication.java @@ -1,6 +1,7 @@ package com.dc.web; import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; @@ -10,6 +11,7 @@ import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; * * @author win */ +@EnableKnife4j @SpringBootApplication( scanBasePackages = { "com.dc.common", "com.dc.system", "com.dc.framework", "com.dc.generator", "com.dc.quartz", "com.dc.web"}, exclude = {DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class}) diff --git a/dc-admin/src/main/java/com/dc/web/config/SwaggerConfig.java b/dc-admin/src/main/java/com/dc/web/config/SwaggerConfig.java index 1527154..1fd5ed4 100644 --- a/dc-admin/src/main/java/com/dc/web/config/SwaggerConfig.java +++ b/dc-admin/src/main/java/com/dc/web/config/SwaggerConfig.java @@ -1,7 +1,6 @@ package com.dc.web.config; import com.dc.common.config.WinConfig; -import io.swagger.annotations.ApiOperation; import io.swagger.models.auth.In; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -20,55 +19,55 @@ import java.util.List; /** * Swagger2的接口配置 - * + * * @author win */ @Configuration -public class SwaggerConfig -{ - /** 系统基础配置 */ +public class SwaggerConfig { + /** + * 系统基础配置 + */ @Autowired private WinConfig winConfig; - /** 是否开启swagger */ + /** + * 是否开启swagger + */ @Value("${swagger.enabled}") private boolean enabled; - /** 设置请求的统一前缀 */ + /** + * 设置请求的统一前缀 + */ @Value("${swagger.pathMapping}") private String pathMapping; /** * 创建API */ - @Bean - public Docket createRestApi() - { - return new Docket(DocumentationType.OAS_30) - // 是否启用Swagger - .enable(enabled) - // 用来创建该API的基本信息,展示在文档的页面中(自定义展示的信息) + @Bean(value = "dockerBean") + public Docket dockerBean() { + //指定使用Swagger2规范 + Docket docket = new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) - // 设置哪些接口暴露给Swagger展示 + //分组名称 + .groupName("用户服务") .select() - // 扫描所有有注解的api,用这种方式更灵活 - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) - // 扫描指定包中的swagger注解 - // .apis(RequestHandlerSelectors.basePackage("com.dc.project.tool.swagger")) - // 扫描所有 .apis(RequestHandlerSelectors.any()) + //这里指定Controller扫描包路径 + .apis(RequestHandlerSelectors.basePackage("com.dc.app.controller")) .paths(PathSelectors.any()) .build() /* 设置安全模式,swagger可以设置访问token */ .securitySchemes(securitySchemes()) .securityContexts(securityContexts()) .pathMapping(pathMapping); + return docket; } /** * 安全模式,这里指定token通过Authorization头请求头传递 */ - private List securitySchemes() - { + private List securitySchemes() { List apiKeyList = new ArrayList(); apiKeyList.add(new ApiKey("Authorization", "Authorization", In.HEADER.toValue())); return apiKeyList; @@ -77,8 +76,7 @@ public class SwaggerConfig /** * 安全上下文 */ - private List securityContexts() - { + private List securityContexts() { List securityContexts = new ArrayList<>(); securityContexts.add( SecurityContext.builder() @@ -91,8 +89,7 @@ public class SwaggerConfig /** * 默认的安全上引用 */ - private List defaultAuth() - { + private List defaultAuth() { AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything"); AuthorizationScope[] authorizationScopes = new AuthorizationScope[1]; authorizationScopes[0] = authorizationScope; @@ -104,8 +101,7 @@ public class SwaggerConfig /** * 添加摘要信息 */ - private ApiInfo apiInfo() - { + private ApiInfo apiInfo() { // 用ApiInfoBuilder进行定制 return new ApiInfoBuilder() // 设置标题 diff --git a/dc-admin/src/main/java/com/dc/web/controller/tool/SwaggerController.java b/dc-admin/src/main/java/com/dc/web/controller/tool/SwaggerController.java index 0d755e0..cc9ca1f 100644 --- a/dc-admin/src/main/java/com/dc/web/controller/tool/SwaggerController.java +++ b/dc-admin/src/main/java/com/dc/web/controller/tool/SwaggerController.java @@ -17,6 +17,6 @@ public class SwaggerController extends BaseController @GetMapping() public String index() { - return redirect("/swagger-ui.html"); + return redirect("/doc.html"); } } diff --git a/dc-app/pom.xml b/dc-app/pom.xml index f4431ac..aa7056c 100644 --- a/dc-app/pom.xml +++ b/dc-app/pom.xml @@ -24,25 +24,19 @@ true - - - io.springfox - springfox-boot-starter - - - - - io.swagger - swagger-models - 1.6.2 - - mysql mysql-connector-java + + + org.postgresql + postgresql + runtime + + com.dc diff --git a/dc-app/src/main/java/com/dc/app/AppApplication.java b/dc-app/src/main/java/com/dc/app/AppApplication.java index 005ef9b..9985bf7 100644 --- a/dc-app/src/main/java/com/dc/app/AppApplication.java +++ b/dc-app/src/main/java/com/dc/app/AppApplication.java @@ -1,6 +1,7 @@ package com.dc.app; import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure; +import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; @@ -8,16 +9,15 @@ import org.springframework.boot.autoconfigure.security.servlet.SecurityAutoConfi /** * 启动程序 - * + * * @author win */ +@EnableKnife4j @SpringBootApplication( - scanBasePackages={"com.dc.system", "com.dc.framework", "com.dc.common", "com.dc.app"}, - exclude = { DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class, SecurityAutoConfiguration.class}) -public class AppApplication -{ - public static void main(String[] args) - { + scanBasePackages = {"com.dc.system", "com.dc.framework", "com.dc.common", "com.dc.app"}, + exclude = {DataSourceAutoConfiguration.class, DruidDataSourceAutoConfigure.class, SecurityAutoConfiguration.class}) +public class AppApplication { + public static void main(String[] args) { // System.setProperty("spring.devtools.restart.enabled", "false"); SpringApplication.run(AppApplication.class, args); System.out.println("闻音启动成功"); diff --git a/dc-app/src/main/java/com/dc/app/config/SwaggerConfig.java b/dc-app/src/main/java/com/dc/app/config/SwaggerConfig.java index ed55e4b..c7e2022 100644 --- a/dc-app/src/main/java/com/dc/app/config/SwaggerConfig.java +++ b/dc-app/src/main/java/com/dc/app/config/SwaggerConfig.java @@ -1,7 +1,6 @@ package com.dc.app.config; import com.dc.common.config.WinConfig; -import io.swagger.annotations.ApiOperation; import io.swagger.models.auth.In; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -51,10 +50,8 @@ public class SwaggerConfig .apiInfo(apiInfo()) // 设置哪些接口暴露给Swagger展示 .select() - // 扫描所有有注解的api,用这种方式更灵活 - .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class)) // 扫描指定包中的swagger注解 - // .apis(RequestHandlerSelectors.basePackage("com.dc.project.tool.swagger")) + .apis(RequestHandlerSelectors.basePackage("com.dc.app.controller")) // 扫描所有 .apis(RequestHandlerSelectors.any()) .paths(PathSelectors.any()) .build() diff --git a/dc-app/src/main/java/com/dc/app/config/WebConfig.java b/dc-app/src/main/java/com/dc/app/config/WebConfig.java index bdf8ade..b82b46b 100644 --- a/dc-app/src/main/java/com/dc/app/config/WebConfig.java +++ b/dc-app/src/main/java/com/dc/app/config/WebConfig.java @@ -21,12 +21,12 @@ public class WebConfig implements WebMvcConfigurer { public void addInterceptors(InterceptorRegistry registry) { registry.addInterceptor(localInterceptor()) .addPathPatterns("/**") - .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v3/**", "/swagger-ui.html/**"); + .excludePathPatterns("/swagger-resources/**", "/webjars/**", "/v3/**", "/swagger-ui.html/**", "/doc.html"); } @Override public void addResourceHandlers(ResourceHandlerRegistry registry) { - registry.addResourceHandler("swagger-ui.html") + registry.addResourceHandler("doc.html") .addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/webjars/**") .addResourceLocations("classpath:/META-INF/resources/webjars/"); diff --git a/dc-system/pom.xml b/dc-system/pom.xml index 49c6ca4..6bbcbfd 100644 --- a/dc-system/pom.xml +++ b/dc-system/pom.xml @@ -17,10 +17,9 @@ - - io.swagger - swagger-models + com.github.xiaoymin + knife4j-spring-boot-starter diff --git a/pom.xml b/pom.xml index 1222cdf..724518d 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,6 @@ 3.1.1 1.2.16 1.21 - 3.0.0 2.3.3 1.4.6 2.0.34 @@ -34,6 +33,7 @@ 3.5.3 5.1.1 3.3.2 + 3.0.3 @@ -84,26 +84,6 @@ ${oshi.version} - - - io.springfox - springfox-boot-starter - ${swagger.version} - - - io.swagger - swagger-models - - - - - - - io.swagger - swagger-models - 1.6.2 - - commons-io @@ -206,6 +186,12 @@ ${dynamic-datasource.version} + + com.github.xiaoymin + knife4j-spring-boot-starter + ${knife4j.version} + + com.dc