Springboot quick and easy to quickly get the favor of the vast number of developers, this set of Springboot series with the latest Springboot 2.0 as the basis, will also mention the different versions of the Springboot change and changes, such as the wrong place to understand, welcome message!
1. Create a new MAVEN project with the following directory structure
2. Introduction of dependency Packages
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency></dependencies>
3. Create a startup class for Springboot
package Com.somta.springboot; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.springbootapplication;@ Springbootapplication public class application { public static void main (String [] args) {springapplication.run (application. ) class
View @springbootapplication source code can be found that the note is @Configuration, @EnableAutoConfiguration, @ComponentScan annotations, in other words springboot Provides a unified annotation to replace the above three annotations, to simplify the configuration of the program, the role of each configuration will be updated in subsequent articles
4. Create a Controller class
@RestController Public class Helloworldcontroller { @RequestMapping ("/helloworld") public String Index ( { return "HelloWorld"; }}
5. Start the Springboot startup class, which appears as shown below to indicate that the project started successfully
5. Finally enter Http://127.0.0.1:8080/helloWorld on the browser to see the interface shown below, your first Springboot project was built successfully
Git code address: Https://gitee.com/songhu/SpringBoot/tree/master/SpringBoot-helloWorld
SpringBoot2.0 one of the new projects HelloWorld