Springboot学习笔记——初见&"Hello World"

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_32360995/article/details/91411220

1、打开网址https://start.spring.io/ ,快速生成springboot的入门级工程,下载保存

2、使用IDEA打开springboot工程

点击“import project”

解压下载的demo.zip,选择pom.xml文件,然后一直next下去

3、编写Hello World

package com.test.demo;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class HelloWorldController {
  /**
   *@author pxChen
   *@date 2019/6/11 9:22
   */
  @RequestMapping("/test")
  public String test() {
    return "Hello World";
  }

}

4、导入web的maven依赖

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

<dependency>
	<groupId>org.springframework.boot</groupId>
	<artifactId>spring-boot-starter-tomcat</artifactId>
	<version>2.2.0.BUILD-SNAPSHOT</version>
</dependency>

5、启动运行,run或debug皆可,springboot内嵌tomcat,故不必安装配置tomcat

运行成功,打开浏览器地址栏输入 http://localhost:8080/test

猜你喜欢

转载自blog.csdn.net/qq_32360995/article/details/91411220
今日推荐