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

Getting started with spring boot (1)

巴扎黑
巴扎黑Original
2017-06-26 11:32:111473browse

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>

    Add in properties

    <java.version>1.8</java.version>

    Add in dependencies

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

  • Create HelloWorldController class

  • @RestController
    public class HelloWorldController {
        @RequestMapping("/hello")
        public String hello(){
            return "Hello World!";
        }
    }
  • 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);
        } 
    }
  • 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!

Statement:
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