标签:str oid version code app 使用 springmvc auto bin
1.1 创建Maven工程
使用idea工具创建一个maven工程,该工程为普通的java工程即可
1.2 添加SpringBoot的起步依赖
SpringBoot要求,项目要继承SpringBoot的起步依赖spring-boot-starter-parent
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.1.RELEASE</version> </parent>
SpringBoot要集成SpringMVC进行Controller的开发,所以项目要导入web的启动依赖
<dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
1.3 编写SpringBoot引导类
要通过SpringBoot提供的引导类起步SpringBoot才可以进行访问
package com.itheima; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplication public class MySpringBootApplication { public static void main(String[] args) { SpringApplication.run(MySpringBootApplication.class); } }
1.4 编写Controller
在引导类MySpringBootApplication同级包或者子级包中创建QuickStartController
package com.itheima.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; @Controller public class QuickStartController { @RequestMapping("/quick") @ResponseBody public String quick(){ return "springboot 访问成功!"; } }
标签:str oid version code app 使用 springmvc auto bin
原文地址:https://www.cnblogs.com/jsit-dj-it/p/12246769.html