Start learning SpringBoot from this blog, and learn Eclipse configuration SpringBoot today. There are two ways for Eclipse to import SpringBoot, one is online and the other is offline.
1. Online installation
Click help->Eclipse Marketplace in Eclipse, search for sts, as shown in the figure below, you can always report the following error, so download the offline package for installation.
2. Offline installation
At the beginning, I downloaded the version of springsource-tool-suite-3.9.4.RELEASE-e4.7.3a-updatesite. Then help->Install New Software->Add->Archive, here I chose Archive because I didn't unzip it, select the components to be installed, and click Next.
3. Create a project using SpringBoot
After the above configuration, you can use SpringBoot to try to create a new web project. After configuration, the New Project page will display the Spring Boot option, select Spring Starter Project.
Configure the project name, version and other information.
Here choose to create a web project
The directory structure of the project after the creation is completed is as follows
4. Test
package com.example.demo; 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; @RestController //@Controller //@ResponseBody @RequestMapping("/sbs") public class helloController { @RequestMapping("/hello") public String Hello(){ return "Hello World"; } }
Here you need to pay attention to the part of the red box in the above figure. @RestController is used here. In fact, you can also use the two annotations annotated below. As for the difference between them, we will learn in the next blog. Click on CuiywTestApplication.java right click Run As->Spring Boot App to start. The following figure is the log of successful startup.
Enter http://localhost:8080/sbs/hello in the browser, you can see the hello world returned in the following figure.