SpringBoot2.0 one of the new projects HelloWorld

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.