1, Springboot Introduction:
The Spring team released an innovative main framework based on the existing Spring framework: Spring Boot. The primary motivation for developing spring boot is to simplify the process of configuring and deploying spring applications. with spring boot, you will be able to develop spring applications in a more flexible way, with minimal configuration of spring, avoiding tedious development steps and boilerplate code and configuration, and more focused on addressing the functional requirements of your application.
2. Project Creation
Create a Maven project ( provided that the Java environment, MAVEN is set up):
Fill in the group id,artifact Id and select Pakaging.
3. Add dependencies
After you create the project successfully, configure Pom.xml:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi= "http://www.w3.org/2001/ Xmlschema-instance " xsi:schemalocation=" http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/ Maven-4.0.0.xsd ">
<modelVersion>4.0.0</modelVersion>
<groupId>SpringBootProject</groupId>
<artifactId>FirstSpringBootProject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<failOnMissingWebXml>false</failOnMissingWebXml>
<start-class>com.springboot.start.applicationStart</start-class>
</properties>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativepath/>
</parent>
<dependencies>
<!--the parent is introduced, so there is no need to specify a version--
<!--contains jar resources such as MVC--
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactid>spring-boot-starter-AOP</artifactId>
</dependency>
<!--add dependency of servlet-API --
<dependency>
<groupId>javax.servlet</groupId>
<artifactid>javax.servlet-API</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactid>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
4. Create control class, start class
Create the Com.first.springboot package and create a Controller class under the package, as follows:
Then write a Firstspringboot method:
Package com.first.springboot;
import org.springframework.web.bind.annotation.GetMapping;
import Org.springframework.web.bind.annotation.RestController;
@RestController
Public class Springstartcontroller {
@GetMapping ("/firstspringboot")
Public String Firstspringboot ()
{
return "Your first springboot Project";
}
}
Then create a startup class:
Package Com.springboot.start;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
Public class Applicationstart {
Public Static void Main (string[] args)
{
Springapplication. Run (Applicationstart. class, args);}
}
5. Start the project
Build Project: Right-click Run As-->maven Install, start Project successfully: At Startup Project Class Applicationstart, right-click Run As-->java application, when Tomcat appears Started on port (s): 8080 (http), description started successfully, entered on browser: Http://localhost:8080//firstspringboot,
At this point, congratulations, your first Springboot app was created successfully.
Springboot: Create the first springboot simple app