The environment in which the project is used:
- Windows 10
- JDK8
- IntelliJ Idea 2017.1.3
- Apache Tomcat 8
- Maven 3.3.3
Create a new spring boot project using idea new project
Select the spring Initializer type.
Fill in the relevant project information
Select Denpendcy
Next, select the web.
Select Path
Next, select the project path, click Finish
The file directory structure of the newly completed project is as follows:
First Spring Boot Project
The Pom.xml is as follows:
<dependencies> <dependency> <groupid>org.springframework.boot</ groupid> <artifactid>spring-boot-starter-web<groupid>org.springframework.boot <artifactid>spring-boot-starter-test<scope>test</dependencies>
Where Spring-boot-starter-web is a Web-enabled module, Spring-boot-starter-test is a module that supports testing.
Add a helloworldcontroller as follows:
Org.springframework.web.bind.annotation.RequestMapping; Org.springframework.web.bind.annotation.RestController; @RestController@RequestMapping("/"index"Hello World"}}
@RestController means that the methods inside are output in JSON format, eliminating the need to add additional JSON configurations.
Start the program
Click SHIFT + F10 or click Run, and when the project starts successfully, visit http://localhost:8080
That means the first spring boot project started successfully.
Spring Boot 1: Create a Spring boot project using idea