1.1.1. Setting the parent of spring boot
<parent> <groupId>org.springframework.boot</groupId> <artifactId> spring-boot-starter-parent</artifactid> <version>1.5.2.RELEASE</version> </parent >
Description: The spring boot project must have the parent set to spring Boot's parent, which contains a large number of default configurations, which greatly simplifies our development.
1.1.2. Importing Spring Boot Web support
<dependency> <groupId>org.springframework.boot</groupId> <artifactId> Spring-boot-starter-web</artifactid> </dependency>
1.1.3. Adding a Spring Boot plugin
<plugin> <groupId>org.springframework.boot</groupId> <artifactId> Spring-boot-maven-plugin</artifactid> </plugin>
1.1.4. Writing the first spring boot application
@Controller @springbootapplication@configurationpublic class Helloapplication { @RequestMapping ("Hello") @ Responsebody public String Hello () { return ' Hello world! "; } public static void Main (string[] args) { springapplication.run (helloapplication.class, args);
Code Description:
1, @SpringBootApplication: The core annotation of the Spring boot project, the main purpose is to turn on automatic configuration. ;
2. @Configuration: This is a configuration class that configures spring;
3, @Controller: Marked this is a SPRINGMVC controller controllers;
4, Main method: In the Main method to start an application, that is: the application of the portal;
1.1.5. Launching the app
In the spring boot project, there are two ways to start a direct run Java application and another is to run through the spring boot maven plugin.
The first type:
The second type:
Start effect:
See the following information to indicate that the boot was successful:
INFO 6188---[main] c.i.springboot.demo.helloapplication:started helloapplication in 3.281 seconds (JVM Running for 3.601)
1.1.6. Testing
Open the browser and enter the address:
Effect:
Isn't it easy?
Writing the first Springboot app