MySoul

啥都不会,连crud都不会,就会个简简单单的mvc

老实了。。跟着学校走。。

2019-9-17 melovemingming

老实了。。。跟着学校走。。。

评论(0) 浏览(9)

扯。。。。

2019-9-17 melovemingming

n年了。。。。。连个框架都不会。。

太扯了。。。。。。就会个wordpresss

评论(0) 浏览(13)

关于api文档

2019-8-8 melovemingming

api文档直接使用easyMock,上传swagger的接口json数据。。

https://easy-mock.com/login


maven导出html文档始终未成功。。。

评论(0) 浏览(162)

spring boot mock测试

2019-8-8 melovemingming

添加依赖


        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>

评论(0) 浏览(198)

swagger2

2019-8-7 melovemingming

依赖

引入相关依赖

 <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>


引入配置类

package com.example.demo.config;

import org.springframework.context.annotation.Configuration;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2Config {

}


更改配置

package com.example.demo.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 Swagger2Config {
    @Bean
    public Docket createRestApi(){
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(this.apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.example.demo.controller"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo(){
        return new ApiInfoBuilder()
                .title("使用swagger2 构建restful apis")
                .description("welcome !")
                .termsOfServiceUrl("http://www.iming.info")
                .version("1.0")
                .build();
    }
}


接口名称

package com.example.demo.controller;

import com.example.demo.domain.Test;
import com.example.demo.service.TestService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@Api(value = "用户控制器", tags = "用户控制器")
public class TestAction {
    @Autowired
    private TestService testService;

    @RequestMapping("/sayHello")
    @ResponseBody
    @ApiOperation("用户列表")
    public Object findALl(){
        List<Test> testList = testService.findAll();
        return testList;
    }

}


生成接口文档

maven plugins 导入

<plugin>
                <groupId>io.github.swagger2markup</groupId>
                <artifactId>swagger2markup-maven-plugin</artifactId>
                <version>1.3.3</version>
                <configuration>
                    <swaggerInput>http://localhost:8080/v2/api-docs</swaggerInput>
                    <outputFile>src/docs/asciidoc/generated/v2-api-doc</outputFile>
                    <config>
                        <swagger2markup.markupLanguage>ASSCIIDOC</swagger2markup.markupLanguage>
                    </config>
                </configuration>
            </plugin>

这里是json文档,文档地址为

http://localhost:8080/v2/api-docs


再引入maven plugin

            <plugin>
                <groupId>org.asciidoctor</groupId>
                <artifactId>asciidoctor-maven-plugin</artifactId>
                <version>1.5.6</version>
                <configuration>
                    <sourceDirectory>src/docs/asciidoc/generated</sourceDirectory>
                    <outputDirector>src/docs/asciidoc/html</outputDirector>
                    <backend>html</backend>
                    <sourceHighlighter>coderay</sourceHighlighter>
                    <attributes>
                        <toc>left</toc>
                    </attributes>
                </configuration>
            </plugin>

评论(0) 浏览(221)

spring boot

2019-8-7 melovemingming


package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.domain.Test;
import org.apache.ibatis.annotations.Mapper;

@Mapper
public interface TestMapper extends BaseMapper<Test> {
}

package com.example.demo.domain;

import lombok.Data;

@Data
public class Test {
    private int id;
    private String name;
}

package com.example.demo.service.Impl;

import com.example.demo.domain.Test;
import com.example.demo.mapper.TestMapper;
import com.example.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service("testService")
public class TestServiceImpl implements TestService {
    @Autowired
    private TestMapper testMapper;

    @Override
    public List<Test> findAll() {
        return testMapper.selectList(null);
    }
}

package com.example.demo.service;

import com.example.demo.domain.Test;

import java.util.List;

public interface TestService {
    public List<Test> findAll();
}

package com.example.demo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan(basePackages = "com.example.demo.mapper")
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

package com.example.demo.controller;

import com.example.demo.domain.Test;
import com.example.demo.service.TestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class TestAction {
    @Autowired
    private TestService testService;

    @RequestMapping("/sayHello")
    @ResponseBody
    public Object findALl(){
        List<Test> testList = testService.findAll();
        return testList;
    }

}

package com.example.demo;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
@MapperScan(basePackages = "com.example.demo.mapper")
public class DemoApplication {

    public static void main(String[] args) {
        SpringApplication.run(DemoApplication.class, args);
    }

}

评论(0) 浏览(202)

哈~ 又回来啦

2019-8-6 melovemingming

回来啦

额。。啥都不会啊。。发愁

评论(1) 浏览(298)

欢迎使用emlog

2019-8-6 melovemingming

恭喜您成功安装了emlog,这是系统自动生成的演示文章。编辑或者删除它,然后开始您的创作吧!

评论(0) 浏览(339)