update demo
This commit is contained in:
parent
7d0cd7f9e3
commit
3d60344158
30
README.md
30
README.md
|
@ -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"
|
||||
}
|
||||
```
|
|
@ -0,0 +1 @@
|
|||
GET localhost:8088/test
|
|
@ -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) {
|
||||
|
|
|
@ -11,7 +11,7 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
* @description:
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/test/eventBus/v1")
|
||||
@RequestMapping()
|
||||
public class TestController {
|
||||
|
||||
|
||||
|
|
|
@ -5,5 +5,5 @@ spring:
|
|||
name: web-test
|
||||
|
||||
server:
|
||||
port: 8081
|
||||
port: 8088
|
||||
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.nebula.web.boot.config.BaseWebMvcConfig
|
Loading…
Reference in New Issue