目录
目录README.md

spring-boot-nebula

开箱即用的web模块

不使用spring-boot-nebula-web搭建项目

需要引入spring boot 各种依赖,指定各种版本,然后编写各种分页基础对象,Result返回对象 比如需要 原先web项目需要使用的返回值比如Response<T> ss;

    @GetMapping("/test")
    public Response<String> test() {
        return Response.success("小奏");
    }

使用spring-boot-nebula-web搭建项目如何简单

  1. 引入依赖

    <dependency>
     <groupId>io.github.weihubeats</groupId>
     <artifactId>spring-boot-nebula-web</artifactId>
     <version>0.0.01</version>
    </dependency>
  2. 编写一个启动类

    @SpringBootApplication
     public class WebApplication {
    
     public static void main(String[] args) {
     TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
     SpringApplication.run(WebApplication.class, args);
     }
     }

然后就可以愉快的写接口了,返回值无需使用Response包装,仅仅需要添加@NebulaResponseBody注解

    @GetMapping("/test")
    @NebulaResponseBody
    public String test() {
        return "小奏";
    }

返回结果

{
  "code": 200,
  "data": "小奏",
  "msg": "success"
}

功能

  1. 统一公司所有spring boot项目的依赖管理

不使用spring-boot-nebula-dependencies可能存在的问题:

  • a项目使用了 redission 3.14 b项目 使用3.61,然后导致相同代码可能运行结果不一致
    • 统一使用spring-boot-nebula-dependencies作为p’a’r’a’m 在boot-common-parent管理公司的所有依赖,以后应用项目无需手动指定各种依赖版本只需引用依赖即可,统一在boot-common-parent管理即可
  1. 提供开箱即用的web-spring-boot-start模块,解决web开发需要手动封装工具类的痛点
  2. 提供统一异常处理
  3. 提供优雅的时间戳转LocalDateTime注解
  4. 提供开箱即用的分页对象
  5. 提供开箱即用的分布式锁
  6. 提供开箱即用的mybatis-plus模块
  7. 提供开箱即用的ddd聚合根模块

demo

使用参考 spring-boot-nebula-samples模块

spring-boot-nebula-web 使用

  1. 引入依赖

    <dependency>
     <groupId>io.github.weihubeats</groupId>
     <artifactId>spring-boot-nebula-web</artifactId>
     <version>0.0.01</version>
    </dependency>
  2. 运行Application.java

  3. 运行 http-test-controller.http中的GET localhost:8088/test

现在不需要将自己的返回对象包裹起来,只需要添加注解@NebulaResponseBody

提供开箱即用的分页对象

时间戳自动转LocalDateTime注解

@GetTimestamp

    @GetMapping("/test")
    @NebulaResponseBody
    public String test(@GetTimestamp LocalDateTime time) {
        return time.toString();
    }

依赖

  • web ```xml
io.github.weihubeats spring-boot-nebula-web 0.0.01 ```
  • 分布式锁

    <dependency>
      <groupId>io.github.weihubeats</groupId>
      <artifactId>spring-boot-nebula-distribute-lock</artifactId>
      <version>0.0.01</version>
    </dependency>
  • ddd聚合根组件

    <dependency>
      <groupId>io.github.weihubeats</groupId>
      <artifactId>spring-boot-nebula-aggregate</artifactId>
      <version>0.0.01</version>
    </dependency>
  • mybatis-plus

    <dependency>
      <groupId>io.github.weihubeats</groupId>
      <artifactId>spring-boot-nebula-mybatis-plus</artifactId>
      <version>0.0.01</version>
    </dependency>

模块说明

spring-boot-nebula-web-common

关于
291.0 KB
邀请码
    Gitlink(确实开源)
  • 加入我们
  • 官网邮箱:gitlink@ccf.org.cn
  • QQ群
  • QQ群
  • 公众号
  • 公众号

©Copyright 2023 CCF 开源发展委员会
Powered by Trustie& IntelliDE 京ICP备13000930号