Spring boot is a new framework provided by the pivotal team designed to simplify the initial setup and development of new spring applications. The framework uses a specific approach to configuration, which eliminates the need for developers to define boilerplate configurations. In this way, boot is committed to becoming a leader in the burgeoning field of rapid application development (rapid application development). That is, spring boot is intended to simplify spring development, and the main idea is to reduce the introduction of spring so that novices can run the program in the spring frame as quickly as possible.
First, install the STS plugin
To create a project in Eclipse using spring boot, you must first install the STS (Spring Tool Suite (STS) for Eclipse) and choose to install it online if the speed is available, otherwise it is recommended that you choose the offline installation.
1. Online Installation
Help, Eclipse Marketplace
Search or select the "Popular" tab, select the STS plugin, install:
2. Offline installation
(1) Download the STS plugin first, download the address as: Https://spring.io/tools/sts/all, download the following zip package.
(2) Help->install New software
(3) Click "Add->archive.", then select the STS plugin that you just downloaded, and give the plugin a name, click "OK" on the line.
(4) Select several components to the end of the IDE to install it, if you wait for a long time, you can install one.
(5) To see if the installation was successful
Window->show View->other to see if there is a spring component, there is a sign that we have successfully installed it.
Second, create the Spring boot project
(1) Create the project and select Spring Starter Project. Fill in the various information related to the project, then next:
(2) Select the desired dependency, then next:
(3) The last "Finish" begins to download the jar package, which takes a long time to process.
Third, the operation of the project
(1) Right-click the main method in DemoApplication, Run as, Spring boot app or Java application, the project can be started.
Package com.example;
Import org.springframework.boot.SpringApplication;
Import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication public
class DemoApplication {public
static void Main (string[] args) {
Springapplication.run (Demoapplication.class, args);
}
}
(2) If you want to run Hello Java world, use the @restcontroller annotation and add the Hello method.
Package com.example;
Import org.springframework.boot.SpringApplication;
Import org.springframework.boot.autoconfigure.SpringBootApplication;
Import org.springframework.web.bind.annotation.RequestMapping;
Import Org.springframework.web.bind.annotation.RestController;
@RestController
@SpringBootApplication Public
class DemoApplication {
@RequestMapping ("/")
String Hello () {
return "Hello Java world!";
}
public static void Main (string[] args) {
springapplication.run (demoapplication.class, args);}
}
How to run our application and see the output of Hello Java world.
The first way is to run the Main method directly:
Select DemoApplication's Main method, right-click Run as->java applicacation, then open the browser input address: http://127.0.0.1:8080/can see hello Java world!.
The second way:
Right-project–> run as–> Maven build–> enter Spring-boot:run in goals, then apply, and finally click Run.