update demo

This commit is contained in:
weihu 2023-08-09 10:11:49 +08:00
parent 7d0cd7f9e3
commit 3d60344158
6 changed files with 37 additions and 5 deletions

View File

@ -11,4 +11,32 @@
## demo
使用参考 [spring-boot-nebula-samples](spring-boot-nebula-samples)模块
使用参考 [spring-boot-nebula-samples](spring-boot-nebula-samples)模块
1. 运行[Application.java](spring-boot-nebula-samples%2Fspring-boot-nebula-web-sample%2Fsrc%2Fmain%2Fjava%2Fcom%2Fnebula%2Fweb%2Fsample%2FApplication.java)
2. 运行 [http-test-controller.http](spring-boot-nebula-samples%2Fspring-boot-nebula-web-sample%2Fsrc%2Fmain%2Fhttp%2Fhttp-test-controller.http)中的`GET localhost:8088/test`
原先web项目需要使用的返回值比如`Response<T> ss;
```java
@GetMapping("/test")
public Response<String> test() {
return Response.success("小奏");
}
```
现在不需要将自己的返回对象包裹起来,只需要添加注解`@NebulaResponseBody`
```java
@GetMapping("/test")
@NebulaResponseBody
public String test() {
return "小奏";
}
```
返回结果
```json
{
"code": 200,
"data": "小奏",
"msg": "success"
}
```

View File

@ -0,0 +1 @@
GET localhost:8088/test

View File

@ -1,13 +1,14 @@
package com.nebula.web.sample;
import org.springframework.boot.SpringApplication;
import java.util.TimeZone;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* Hello world!
*
*/
@SpringBootApplication
public class Application {
public static void main(String[] args) {

View File

@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
* @description:
*/
@RestController
@RequestMapping("/test/eventBus/v1")
@RequestMapping()
public class TestController {

View File

@ -5,5 +5,5 @@ spring:
name: web-test
server:
port: 8081
port: 8088

View File

@ -0,0 +1,2 @@
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.nebula.web.boot.config.BaseWebMvcConfig