File-->New-->Project-->Spring Initializr 点击next

填写Artifact项目名称

勾选Web 这里标识了spring boot版本号 2.0.1 3月1号发布 aliyun等第三方镜像还没有包 需要到spring.io/下载 很慢 所以选择用1.51版本

修改项目地址 点击Finish

项目结构

新建一个TestController
package com.example;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@RequestMapping("/hello")
public String hello() {
return "hello world";
}
}
找到程序自动生成的XychwlApplication,会有一个@SpringBootApplication的注解,这个注解用来标明这个类是程序的入口,在main方法上右键,点击Run XychwlApplication

出现端口号 项目启动成功

测试:
在地址栏中输入http://localhost:8080/hello

网友评论