1.org.springframework.boot.context.logging.ClasspathLoggingApplicationListener - Application failed to start with classpath
一般发生在项目文件的编码不匹配,绝大部分发生在对于yml文件或者properties文件上,而且是出现在配置文件的中文注释上,把中文注释删除就没有错了。
改了好久,最后把application.yml的中文注释删掉,成功
2.spring boot配置swagger2
first.在pom.xml下添加依赖
<!--Swagger-UI API文档生产工具--> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger-ui</artifactId> <version>2.9.2</version> </dependency> <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-swagger2</artifactId> <version>2.9.2</version> </dependency>
添加好之后用maven同步一下依赖
second.在XXXApplication同级目录下建一个config软件包,新建SwaggerConfig类
package com.example.test.config; 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 springfox.documentation.service.ApiInfo; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; @Configuration @EnableSwagger2 public class SwaggerConfig { @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() .apis(RequestHandlerSelectors.basePackage("com.example.test.controller")) .paths(PathSelectors.any()) // 可以根据url路径设置哪些请求加入文档,忽略哪些请求 .build() .apiInfo(apiInfo()); } private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("接口文档API") //设置文档的标题 .description("Service API 接口文档") // 设置文档的描述 .version("1.0") // 设置文档的版本信息-> 1.0.0 Version information //.termsOfServiceUrl("http://www.baidu.com") // 设置文档的License信息->1.3 License information .build(); } }
搭建完成
3.配置thrift及实现简单实例
官网下载编译器然后放到要用的目录下,(偷懒不想设置环境变量),
现在开始做一个实例来看看
准备好的idl文件
两个double,一个是cpu使用率,另一个是ram使用率
一个方法getProcessInfo(),返回这两个值
使用编译器通过这个idl文件生成上图中iface包下的两个类
把依赖和这两个东西都搞到thrift.demo里去
自己写一个service的impl(这里实现getProcessInfo方法),再写一个server端,再写一个client端,用的时候把server端打开,然后就可以用client端愉快的玩耍了!
demo的大概结构如下图: