Springboot开发随笔(未完成)

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的大概结构如下图:

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值