Jboot v3.6.9 released, powerful @JsonBody

Jboot is a microservice framework developed based on JFinal, JFinal-Undertow, Dubbo, Seata, Sentinel, ShardingSphere, Nacos, etc., to help developers lower the threshold for microservice development. At the same time, it perfectly supports multiple maven modules under idea and eclipse, and hot-loading resource files such as java code, html, css, js, etc. Shuangshuang development, happy life.

So far, Jboot has been open source for more than 4 years, iterated 160+ versions, and has been used by more than 1,000 companies, including many well-known listed companies.

Jboot V3.6.9 mainly enhances the interaction and rendering capabilities of Jboot and front-end Json. The @JsonBody annotation is added for receiving front-end Json data and refactoring ErrorRender, which can be friendly to the front-end when a program error occurs Experience.

@JsonBody is very powerful. For example, the content of Json passed in from the front end is as follows:

[1,2,3]

 The following methods can receive data normally:

 public void method1(@JsonBody() int[] beans) {
        System.out.println("beans--->" + beans);
        renderText("ok");
}



 public void method2(@JsonBody() String[] beans) {
        System.out.println("beans--->" + beans);
        renderText("ok");
}



 public void method3(@JsonBody() List beans) {
        System.out.println("beans--->" + beans);
        renderText("ok");
}


 public void method4(@JsonBody() Set beans) {
        System.out.println("beans--->" + beans);
        renderText("ok");
}


 public void method5(@JsonBody() List<Integer> beans) {
        System.out.println("beans--->" + beans);
        renderText("ok");
}


 public void method6(@JsonBody() Set<Integer> beans) {
        System.out.println("beans--->" + beans);
        renderText("ok");
}



 public void method7(@JsonBody() List<String> beans) {
        System.out.println("beans--->" + beans);
        renderText("ok");
}


 public void method8(@JsonBody() Set<String> beans) {
        System.out.println("beans--->" + beans);
        renderText("ok");
}

If the front end passes in the following Json data:

{
   "aaa":{
      "bbb":[1,2,3]
      }
}

Just add the corresponding prefix to @JsonBody, for example:

 public void method1(@JsonBody("aaa.bbb") int[] beans) {
        System.out.println("beans--->" + beans);
        renderText("ok");
}

The support for Java Bean is also very friendly. For example, the code of MyBean is as follows:

public class MyBean {
    private String id;
    private int age;
    private BigInteger amount;

    //getter setter
}

The front-end incoming data is as follows:

{
  "aaa":{
     "bbb":{
         "id":"abc",
         "age":17,
         "amount":123
      }
   }
 }

The controller back-end receiving code is as follows:

public void bean(@JsonBody("aaa.bbb") MyBean bean) {
    System.out.println("bean--->" + bean);
    renderText("ok");
}

Or, the backend can directly use a Map to receive:

 public void map(@JsonBody("aaa.bbb") Map map) {
        System.out.println("map--->" + map);
        renderText("ok");
}

You can also directly specify the data type of the Map using Map reception:

  public void map(@JsonBody("aaa.bbb") Map<String, String> map) {
        System.out.println("map--->" + map);
        renderText("ok");
  }

If the front end passes in a Bean array, for example:

{
    "aaa":{
        "bbb":[
            {
                "id":"abc",
                "age":17,
                "amount":123
            },
            {
                "id":"abc",
                "age":17,
                "amount":123
            }
        ]
    }
}

The backend can receive data in the following ways, for example:

  public void list(@JsonBody("aaa.bbb") List<MyBean> list) {
        System.out.println("list--->" + list);
        renderText("ok");
  }

or

public void set(@JsonBody("aaa.bbb") Set<MyBean beans) {
        System.out.println("array--->" + beans);
        renderText("ok");
}

or

public void array(@JsonBody("aaa.bbb") MyBean[] beans) {
        System.out.println("array--->" + beans);
        renderText("ok");
}

@JsonBody has more support, so the space is limited and no more examples.

 

Jboot mainly has the following characteristics:

  • 1. Rapid development of MVC + ORM based on JFinal
  • 2. Based on ShardingSphere + Seata distributed transaction and sub-database sub-table
  • 3. RPC implementation based on Dubbo or Motan
  • 4. Sentinel-based distributed current limiting and degradation
  • 5. Distributed configuration center based on Apollo and Nacos
  • 6. Distributed secondary cache based on EhCache and Redis

Jboot v3.6.9 updates are as follows:

  • New: AttachmentManager adds several methods for saving files.
    New: Controller parameter adds support for @JsonBody.
    New: Http tool module adds more configurations to facilitate the configuration of https in fatjar mode.
    New certificates : ErrorRender automatic judgment Does the front end require json rendering? When the request header is application/json, the wrong json is automatically rendered.
    Optimization: JbootSimpleApplication to make the code more concise.
    Optimization: Optimized cache interceptor to construct the method key to improve performance.
    Optimization: Add JbootAccessTokenCache by default 2 hours of caching time
    Optimization: LocalAttachmentContainer, when saving files by default, the same file verification is performed on the file.
    Optimization: JwtManager returns a constant map when there is an error or no Jwt data in the Jwt parsing.
    Optimization: Upgrade JFinal, Undertow, Jackson, etc. to the latest version

Development documents:

https://jbootprojects.gitee.io/docs/

At the same time, Jboot officially launched the enterprise-level development framework JbootAdmin, details  https://jbootprojects.gitee.io/docs/jbootadmin/

maven dependency:

<dependency>
    <groupId>io.jboot</groupId>
    <artifactId>jboot</artifactId>
    <version>3.6.9</version>
</dependency>

Hello World:

@RequestMapping("/")
public class HelloworldController extends JbootController {

    public void index(){
        renderText("hello world");
    }

    public static void main(String[] args){
        JbootApplication.run(args);
    }
}

Guess you like

Origin www.oschina.net/news/123047/jboot-3-6-9-released