内容简介:之前配置过springboot,相比ssm要简单很多,现在记录一下ssm的配置最后启动项目,访问swagger接口文档的路径一定要对,不然一直报404,你以为你没配置对,其实是你路径不对,笔者在这里表示有很痛的领悟
之前配置过springboot,相比ssm要简单很多,现在记录一下ssm的配置
在pom.xml中加入依赖
<!--swagger本身不支持spring mvc的,springfox把swagger包装了一下,让他可以支持springmvc-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
</dependency>
添加配置类SwaggerConfig.java
@WebAppConfiguration
@EnableSwagger2
@EnableWebMvc
@ComponentScan(basePackages = "com.maxcore.controller")
public class SwaggerConfig {
@Bean
public Docket customDocket() {
//
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.any())
.build()
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
Contact contact = new Contact("娜", "https://www.baidu.me", "baidu_666@icloud.com");
return new ApiInfo("仿简书前台API接口",//大标题 title
"Swagger测试demo",//小标题
"0.0.1",//版本
"www.baidu.com",//termsOfServiceUrl
contact,//作者
"Blog",//链接显示文字
"https://www.baidu.me"//网站链接
);
}
}
在dispatcher-servlet.xml(springmvc的配置文件)中加入如下配置
<bean class="com.maxcore.config.SwaggerConfig" />
<mvc:resources mapping="swagger-ui.html" location="classpath:/META-INF/resources/" />
<mvc:resources mapping="/webjars/**" location="classpath:/META-INF/resources/webjars/" />
要在controller层添加注解
最后启动项目,访问swagger接口文档的路径一定要对,不然一直报404,你以为你没配置对,其实是你路径不对,笔者在这里表示有很痛的领悟
笔者的本地的访问路径是 http://localhost/jianShuSSM_w...
一般都是
http://ip地址 :端口(默认80,不显示)/项目名/swagger-ui.html
终
以上就是本文的全部内容,希望本文的内容对大家的学习或者工作能带来一定的帮助,也希望大家多多支持 码农网
猜你喜欢:- 配置node服务器并且链接微信公众号接口配置(超详细)
- Nuxt+Express后端api接口配置与实现方式
- 如何架构一个中后台项目的前端部分(接口配置篇)
- 一段万能的Nginx接口实现反向代理配置值得收藏!
- xfire: 简单优雅、高度可配置的fetch接口批量生成工具
- gcs v0.1.1 加入接口缓存,Go 配置管理平台
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
An Introduction to Genetic Algorithms
Melanie Mitchell / MIT Press / 1998-2-6 / USD 45.00
Genetic algorithms have been used in science and engineering as adaptive algorithms for solving practical problems and as computational models of natural evolutionary systems. This brief, accessible i......一起来看看 《An Introduction to Genetic Algorithms》 这本书的介绍吧!
JSON 在线解析
在线 JSON 格式化工具
html转js在线工具
html转js在线工具