swagger

2020年,这10 个 非常热门的Java 微服务框架,你知道吗?

雨燕双飞 提交于 2020-03-20 14:50:15
1、Spring Boot Java 构建 Spring 应用程序已经有很长一段时间了,Spring Boot 是 Spring 的一个特定版本,它通过对配置细节的处理,使微服务构建更加简便。创建 Spring Boot 旨在自启动任何类型的 Spring 项目,而不仅仅是微服务。应用程序完成后,Spring Boot 将在 web 服务器中混合,并输出一个 JAR 文件,JVM 除外。你可以将其视为原始 Docker 容器。这也是许多负责构建微服务的开发者都非常喜欢 Spring Boot 的原因。 使用 Spring 开发微服务遵循与 Web 应用相同的 MVC 理念。该框架享有多年 Java 开发中建立的所有深度连接,包括所有主要和次要数据存储、LDAP 服务器和 Apache Kafka 等消息传递工具的集成。还有许多用于维护运行服务器集合的小特性,比如 Spring Vault,这是一种用于维护生产环境中服务器所需的密码的工具。所有这些优点都说明了为什么 Java 程序员多年来一直喜欢 Spring Boot 的原因。 2、Eclipse MicroProfile 2016 年,Java Enterprise 社区决定清理 Java Enterprise Edition 中的内容,以便人们可以使用经典部件构建简单的微服务。他们去除了大量的库,但保留了处理 REST 请求

Asp.net core Swagger custom UI page GetType().GetTypeInfo().Assembly.GetManifestResourceStream()

余生颓废 提交于 2020-03-20 12:32:01
3 月,跳不动了?>>> GetType (). GetTypeInfo ().Assembly. GetManifestResourceStream ("<Solution Name><Page Name>.Hmtl") Read failure. Solution: Change html build action of attributes to "Embedded resource". 来源: oschina 链接: https://my.oschina.net/it110/blog/3207078

springboot项目引入Swagger2步骤

陌路散爱 提交于 2020-03-19 22:40:11
3 月,跳不动了?>>> 第一步:增加jar包,引入最新版本2.9.2,访问的时候会报错java.lang.NumberFormatException,排除报错的包可以解决、也可以引入旧的jar包 <!-- 添加Swagger2依赖,用于生成接口文档 --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> <!-- 报错信息:java.lang.NumberFormatException: For input string: “” 排除jar包引用旧的jar包解决问题 --> <exclusions> <exclusion> <groupId>io.swagger</groupId> <artifactId>swagger-annotations</artifactId> </exclusion> <exclusion> <groupId>io.swagger</groupId> <artifactId>swagger-models</artifactId> </exclusion> </exclusions> </dependency> <!-- 引用旧的jar 排除新jar包中的问题 start --

web api 配置 Swagger

隐身守侯 提交于 2020-03-18 17:02:14
某厂面试归来,发现自己落伍了!>>> swagger安装 Nuget搜索swagger,然后安装Swashbuckle 安装好了后 删除多余的SwaggerUI文件夹 删除多余的配置类SwaggerNet 4.添加接口注释 完成上面三部运行项目,可以看到接口描述已经生成,浏览地址http://xxx/Swagger。但是没有接口的注释,下面添加接口注释 项目属性->勾选生成xml文档文件 修改SwaggerConfig文件 // c.IncludeXmlComments(GetXmlCommentsPath()); // 设置接口描述xml路径地址 c.IncludeXmlComments( string .Format( " {0}/bin/SwaggerDemo.XML " , System.AppDomain.CurrentDomain.BaseDirectory)); 给接口添加注释,即可看到参数及方法描述了 这样好了后发现没有 具体接口的名称 这时候找到App_Start 里面的WebApiConfig 这个文件 修改下 routeTemplate 修改为 这样配置Swagger 就完成了 来源: oschina 链接: https://my.oschina.net/u/2494395/blog/3197521

生产环境下springboot中配置禁用swagger

穿精又带淫゛_ 提交于 2020-03-18 15:56:54
某厂面试归来,发现自己落伍了!>>> 一、序言 在生产环境下,我们需要关闭swagger配置,避免暴露接口的这种危险行为。 二、方法: 禁用方法1:使用注解@Profile({"dev","test"}) 表示在开发或测试环境开启,而在生产关闭。(推荐使用) 禁用方法2:使用注解@ConditionalOnProperty(name = "swagger.enable", havingValue = "true") 然后在测试配置或者开发配置中 添加 swagger.enable = true 即可开启,生产环境不填则默认关闭Swagger. 如方法1: package com.left; 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

springboot 线上禁用 swagger

吃可爱长大的小学妹 提交于 2020-03-18 15:48:34
某厂面试归来,发现自己落伍了!>>> 禁用方式1:使用注解 @Profile ({ "dev" }) 表示在开发环境开启,而在生产关闭 禁用方式2:使用注解 @ConditionalOnProperty ( name = "enabled" , prefix = "swagger" , havingValue = "true" , matchIfMissing = true ) 然后在 配置文件中配置如下信息 swagger.enable = true 即可开启,生产环境不配置则默认关闭 禁用配置成功后访问 来源: oschina 链接: https://my.oschina.net/u/3690153/blog/3197484

springboot日记之初入swag

穿精又带淫゛_ 提交于 2020-03-17 22:43:54
## 什么是swag? Swagger 是一个规范和完整的框架,用于生成、描述、调用和可视化 RESTful 风格的 Web 服务。总体目标是使客户端和文件系统作为服务器以同样的速度来更新。文件的方法,参数和模型紧密集成到服务器端的代码,允许API来始终保持同步。简单来说,可以更友好的展示自己对外的API,调用、测试更加方便、轻松。 下面的操作都是以maven构建的springboot项目为基础。 首先要做的就是引入swag的jar包 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.5.0</version> </dependency> 配置config类 @Configuration @EnableSwagger2 public class Swagger2 { @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select() // 为当前包路径 .apis(RequestHandlerSelectors.basePackage("learn.controller"))

Springboot集成Swagger

霸气de小男生 提交于 2020-03-17 15:28:31
1.添加相关依赖 <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.在主配置文件中配置swagger package com . example . demo ; import org . springframework . boot . SpringApplication ; import org . springframework . boot . autoconfigure . SpringBootApplication ; import org . springframework . context . annotation . Bean ; import org . springframework . context . annotation . ComponentScan ; import springfox

springboot配置swagger

霸气de小男生 提交于 2020-03-17 13:44:23
某厂面试归来,发现自己落伍了!>>> 一、springboot配置swagger后自动生成文档 方便测试 二、集成步骤(假设springboot已经搭建完成 可运行) 2.1、引入pom文件 <!-- swagger --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.5.0</version> </dependency> <!-- swagger-ui --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.5.0</version> </dependency> 2.2、config类 package com.mao.swagger.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import io.swagger.annotations.ApiOperation; import

springboot 2.0.8 整合swager

混江龙づ霸主 提交于 2020-03-17 12:45:40
某厂面试归来,发现自己落伍了!>>> 1、引入swager pom依賴 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> </dependency> <!-- swagger-ui --> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> </dependency> <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 --> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> </dependency> <dependency> <groupId>org.javassist</groupId> <artifactId>javassist</artifactId> <version>3.26.0-GA</version> </dependency> 其中 commons-lang3