Overview
I haven't played Spring Boot yet, and now more and more companies are using it, so I have to learn it. This article is the beginning of Spring Boot, which briefly introduces how to create and run a Spring Boot project.
Environmental preparation
1. JDK 1.8
2. IDEA
Create Spring Boot Project
new project
Select Spring Initializr
After selecting to use JDK1.8, click Next.
Fill in Group and Artifact
What I wrote here is
Group: com.springboot
Artifact:study
At the same time, use Maven to build the program. Click Next after selecting.
Select the version and components of Spring Boot
For the convenience of demonstration, please check the web component first. Click Next after selecting.
Modify the project name
The project name used in this article is
spring_boot_study
After modifying, click the finish button.
Run Spring Boot Program
After the above steps, Spring Boot has generated a startup class for us by default called StudyApplication , and we will write a Hello program based on this.
package com.springboot;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;@SpringBootApplication@RestControllerpublic class StudyApplication { @RequestMapping("/hello") public String hello() { return "hello,Spring Boot"; } public static void main(String[] args) { SpringApplication.run(StudyApplication.class, args); }}Run this main method directly in IDEA and you can start the Spring Boot program. The access path is as follows:
http://localhost:8080/hello
The output result is as follows
hello, Spring Boot
You can see from the startup log that the default port number is 8080.
At this point, a simple Spring Boot program was successfully built.
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.