以前配置過springboot,相比ssm要簡單不少,如今記錄一下ssm的配置html
<!--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>
@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"//網站連接 ); } }
<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/" />
筆者的本地的訪問路徑是 http://localhost/jianShuSSM_war/swagger-ui.htmljava
通常都是 http://ip地址:端口(默認80,不顯示)/項目名/swagger-ui.htmlgit
githubgithub
我的網站web