Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of developing demo with SpringBoot basic web

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the SpringBoot basic web development demo method related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this SpringBoot basic web development demo method article will have a harvest, let's take a look at it.

1. Import Lombok dependencies in pom.xml in the springboot project you created

Org.projectlombok lombok 1.18.6

two。 Install the Lombok plug-in

3. Create a package of the entity class at the sibling of the main startup class, create the entity class in the package, and use Lombok on the entity class

Package com.hxy.bean;import com.fasterxml.jackson.annotation.JsonFormat;import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;import java.util.Date;@Data / / replaces the getter, setter and toString methods @ AllArgsConstructor / / create a parameter constructor @ NoArgsConstructor / / create a no-parameter constructor public class Car {private Integer id; private String name; private double price; @ JsonFormat (pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") private Date createDate }

4. Create the control layer package at the sibling of the main startup class, and create the controller class

Package com.hxy.controller;import com.offcn.po.Car;import org.springframework.cache.CacheManager;import org.springframework.stereotype.Controller;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.ResponseBody;import org.springframework.web.bind.annotation.RestController;import java.util.ArrayList;import java.util.List @ RestController / / replaces @ ResponseBody and @ Controller annotations @ RequestMapping ("/ car") public class CarController {@ RequestMapping ("/ findone") public Car findOneCar () {Car car = new Car (1, "toyo", 1999.99Fjue new Date (), "13567890001"); return car;}} this is the end of the article on "SpringBoot basic web methods for developing demo". Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "SpringBoot basic web method of developing demo". If you want to learn more knowledge, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report