1、创建一个新的maven工程

一、SpringBoot之Hello World

2、pom.xml里面添加Spring Boot依赖

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>1.5.9.RELEASE</version>
</parent>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
</dependencies>

3、添加主程序类,程序入口

@SpringBootApplication
public class HelloWorldMainApplication {

    public static void main(String[] args) {

        SpringApplication.run(HelloWorldMainApplication.class,args);
    }
}

4、编写测试Controller

@Controller
public class HelloController {

    @RequestMapping("/hello")
    @ResponseBody
    public String Hello(){
        return "HelloWorld";
    }
}

5、以普通方式或者debug方式启动Spring Boot项目

一、SpringBoot之Hello World

6、访问路径,得到相应

一、SpringBoot之Hello World

成功完成第一个SpringBoot项目。

相关文章:

  • 2021-12-13
  • 2021-11-30
  • 2021-05-10
  • 2021-05-05
  • 2021-05-22
  • 2021-08-31
  • 2021-06-08
猜你喜欢
  • 2021-10-04
  • 2021-07-30
  • 2021-08-14
  • 2021-05-26
  • 2021-09-07
  • 2021-07-27
  • 2022-12-23
相关资源
相似解决方案