开箱即用的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
搭建项目如何简单
<dependency>
<groupId>io.github.weihubeats</groupId>
<artifactId>spring-boot-nebula-web</artifactId>
<version>0.0.01</version>
</dependency>
@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"
}
spring boot
项目的依赖管理不使用spring-boot-nebula-dependencies
可能存在的问题:
spring-boot-nebula-dependencies
作为p'a'r'a'mboot-common-parent
管理公司的所有依赖,以后应用项目无需手动指定各种依赖版本只需引用依赖即可,统一在boot-common-parent
管理即可web-spring-boot-start
模块,解决web开发需要手动封装工具类的痛点LocalDateTime
注解mybatis-plus
模块ddd
聚合根模块使用参考 spring-boot-nebula-samples模块
<dependency>
<groupId>io.github.weihubeats</groupId>
<artifactId>spring-boot-nebula-web</artifactId>
<version>0.0.01</version>
</dependency>
GET localhost:8088/test
现在不需要将自己的返回对象包裹起来,只需要添加注解@NebulaResponseBody
LocalDateTime
注解@GetTimestamp
@GetMapping("/test")
@NebulaResponseBody
public String test(@GetTimestamp LocalDateTime time) {
return time.toString();
}
<dependency>
<groupId>io.github.weihubeats</groupId>
<artifactId>spring-boot-nebula-web</artifactId>
<version>0.0.01</version>
</dependency>
<dependency>
<groupId>io.github.weihubeats</groupId>
<artifactId>spring-boot-nebula-distribute-lock</artifactId>
<version>0.0.01</version>
</dependency>
<dependency>
<groupId>io.github.weihubeats</groupId>
<artifactId>spring-boot-nebula-aggregate</artifactId>
<version>0.0.01</version>
</dependency>
<dependency>
<groupId>io.github.weihubeats</groupId>
<artifactId>spring-boot-nebula-mybatis-plus</artifactId>
<version>0.0.01</version>
</dependency>
BaseDO
,一些常用的类型处理器,比如数组