第一种
New Project
Select Simple Project
Config Project
修改pom.xml
4.0.0
com.happy
MyNas
0.0.1-SNAPSHOT
MyNas
简单管理文件
org.springframework.boot
spring-boot-starter-parent
2.6.7
8
8
org.springframework.boot
spring-boot-starter-web
添加package
添加NasApplication
package com.happy.controller;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class NasApplication {
public static void main(String[] args) {
// TODO Auto-generated method stub
SpringApplication.run(NasApplication.class, args);
}
}
添加LoginController
package com.happy.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class LoginController {
@RequestMapping("/login")
public String login() {
return "please login !!!";
}
}
启动项目
测试Web
第二种
登录https://start.spring.io/
点击下面图标
解压到eclipse工作目录
导入项目
选择目录
效果展示