Showing
2 changed files
with
78 additions
and
0 deletions
| 1 | +package com.iclear.ocr.ocrapi; | ||
| 2 | + | ||
| 3 | +import org.slf4j.Logger; | ||
| 4 | +import org.slf4j.LoggerFactory; | ||
| 5 | +import org.springframework.boot.SpringApplication; | ||
| 6 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
| 7 | +import org.springframework.boot.builder.SpringApplicationBuilder; | ||
| 8 | +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | ||
| 9 | +import org.springframework.context.annotation.Bean; | ||
| 10 | +import org.springframework.web.client.RestTemplate; | ||
| 11 | +import org.springframework.web.context.request.async.DeferredResult; | ||
| 12 | +import springfox.documentation.builders.PathSelectors; | ||
| 13 | +import springfox.documentation.service.ApiInfo; | ||
| 14 | +import springfox.documentation.service.Contact; | ||
| 15 | +import springfox.documentation.spi.DocumentationType; | ||
| 16 | +import springfox.documentation.spring.web.plugins.Docket; | ||
| 17 | + | ||
| 18 | +@SpringBootApplication | ||
| 19 | +public class OcrapiServerApplication extends SpringBootServletInitializer { | ||
| 20 | + private static final Logger logger = LoggerFactory.getLogger(OcrapiServerApplication.class); | ||
| 21 | + | ||
| 22 | + public static void main(String[] args) { | ||
| 23 | + logger.info("Spring Boot OcrapiServerApplication Begin............."); | ||
| 24 | + SpringApplication.run(OcrapiServerApplication.class, args); | ||
| 25 | + logger.info("Spring Boot OcrapiServerApplication End............."); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + @Override | ||
| 29 | + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { | ||
| 30 | + return application.sources(OcrapiServerApplication.class); | ||
| 31 | + } | ||
| 32 | + | ||
| 33 | + @Bean | ||
| 34 | + public Docket prodApi() { | ||
| 35 | + return new Docket(DocumentationType.SWAGGER_2) | ||
| 36 | + .groupName("prod") | ||
| 37 | + .genericModelSubstitutes(DeferredResult.class) | ||
| 38 | + // .genericModelSubstitutes(ResponseEntity.class) | ||
| 39 | + .useDefaultResponseMessages(false) | ||
| 40 | + .forCodeGeneration(false) | ||
| 41 | + .pathMapping("/")//api测试请求地址 | ||
| 42 | + .select() | ||
| 43 | + .paths(PathSelectors.regex("/*.*"))//过滤的接口 | ||
| 44 | + .build() | ||
| 45 | + .apiInfo(prodApiInfo()); | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + private ApiInfo prodApiInfo() { | ||
| 49 | + Contact contact = new Contact("IClearProject", "http://localhost:8080", "yang.li@erry.com"); | ||
| 50 | + ApiInfo apiInfo = new ApiInfo("Spring Boot Prod API接口",//大标题 | ||
| 51 | + "REST风格API",//小标题 | ||
| 52 | + "0.1",//版本 | ||
| 53 | + "http://www.erry.vip",//服务网址条款 | ||
| 54 | + contact.getName(),//作者 | ||
| 55 | + "主页",//链接显示文字 | ||
| 56 | + "http://www.erry.vip"//网站链接 | ||
| 57 | + ); | ||
| 58 | + return apiInfo; | ||
| 59 | + } | ||
| 60 | + | ||
| 61 | + @Bean | ||
| 62 | + public RestTemplate restTemplate() { | ||
| 63 | + return new RestTemplate(); | ||
| 64 | + } | ||
| 65 | +} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +package com.iclear.ocr.ocrapi; | ||
| 2 | + | ||
| 3 | +import org.springframework.boot.builder.SpringApplicationBuilder; | ||
| 4 | +import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; | ||
| 5 | + | ||
| 6 | +public class ServletInitializer extends SpringBootServletInitializer { | ||
| 7 | + | ||
| 8 | + @Override | ||
| 9 | + protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { | ||
| 10 | + return application.sources(OcrapiServerApplication.class); | ||
| 11 | + } | ||
| 12 | + | ||
| 13 | +} |
-
Please register or login to post a comment