springboot 简单的整合 swagger

下面是swagger的官网
https://swagger.io/

1 配置pom


io.springfox
springfox-swagger2
s p r i n g f o x − v e r s i o n < / v e r s i o n > < / d e p e n d e n c y > < d e p e n d e n c y > < g r o u p I d > i o . s p r i n g f o x < / g r o u p I d > < a r t i f a c t I d > s p r i n g f o x − s w a g g e r − u i < / a r t i f a c t I d > < v e r s i o n > {springfox-version}</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version> springfoxversion</version></dependency><dependency><groupId>io.springfox</groupId><artifactId>springfoxswaggerui</artifactId><version>{springfox-version}

配置版本
2.7.0

2 配置yml/application
#swagger
springfox.documentation.swagger.v2.path=/docs

3 启动swagger
在这里插入图片描述

4 编写config类
@javax.annotation.Generated(value = “io.swagger.codegen.languages.SpringCodegen”, date = “2020-09-02T09:51:51.983Z”)

@Configuration
public class SwaggerDocumentationConfig {

ApiInfo apiInfo() {
	return new ApiInfoBuilder().title("测试用的标题")
			.description(
					"这是个测试类")
			.license("Apache 2.0").licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html")
			.termsOfServiceUrl("http://www.apache.org/licenses/LICENSE-2.0.html").version("1.0.1").contact(new Contact("a", "b", "apiteam@swagger.io")).build();
}

@Bean
public Docket customImplementation() {
	return new Docket(DocumentationType.SWAGGER_2).select()
			.apis(RequestHandlerSelectors.basePackage("com.xj")).build()
			/*.directModelSubstitute(org.threeten.bp.LocalDate.class, java.sql.Date.class)
			.directModelSubstitute(org.threeten.bp.OffsetDateTime.class, java.util.Date.class)*/
			.apiInfo(apiInfo());
}

}

启动后访问:
http://localhost:8080/swagger-ui.html

看到下面的页面,启动就成功了
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值