传统方法
a: 创建web工程
b: 配置springmvc web.xml
c: 编写controller
springboot
1 创建springboot 工程 必须继承spring-boot-stater-parent
2 编写controller
@RestController //相当于Controller ResponseBody @RequestMapping("/user") public class UserController { @GetMapping("/json") public String getJson(){ return "Hello World!"; } }
3 主启动类
//主启动类
@SpringBootApplication public class SpringbootMybatisApplication { public static void main(String[] args) { SpringApplication.run(SpringbootMybatisApplication.class, args); } }
4 启动main