Home > Java > javaTutorial > Getting started with spring boot (1)

Getting started with spring boot (1)

巴扎黑
Release: 2017-06-26 11:32:11
Original
1480 people have browsed it

spring boot entry operation

Create HelloWorld
  • Create a new maven project and select the artifact id as maven-archetype-quicktype

  • Create pom, add in project

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.5.4.RELEASE</version>
    </parent>
    Copy after login

    Add in properties

    <java.version>1.8</java.version>
    Copy after login

    Add in dependencies

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    Copy after login
  • update maven

  • Create HelloWorldController class

  • @RestController
    public class HelloWorldController {
        @RequestMapping("/hello")
        public String hello(){
            return "Hello World!";
        }
    }
    Copy after login
  • Write startup class APP.java

    @SpringBootApplication
    public class App 
    {
        public static void main( String[] args )
        {
             System.out.println( "console  Hello World!" );
             SpringApplication.run(App.class, args);
        } 
    }
    Copy after login
  • Browse Enter localhost:8080/hello

The above is the detailed content of Getting started with spring boot (1). For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template