NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
//pom.xml文件中添加 ~~~ <!-- spring-boot-starter-parent整合第三方常用框架依赖信息(各种依赖信息) --> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.0.0.RELEASE</version> </parent> <!-- spring-boot-starter-web是springboot整合springMVC web 实现原理:Maven依赖继承关系 --> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> ~~~ ~~~ //controller中 /** * springboot启动原理:springmvc 注解方式启动 内置http服务器(默认是tomcat) * @author Administrator * */ //@RestController注解表示该类中的所有方法返回json格式 @ResponseBody+@Controller //@EnableAutoConfiguration注解作用:扫包范围默认在当前类里面 @RestController @EnableAutoConfiguration public class MemberController { @RequestMapping("/memberIndex") public String memberIndex(){ return "springboot2.0"; } public static void main(String[] args) { //整个程序入口 启动springboot项目 创建内置tomcat服务器 使用tomcat加载springmvc 注解启动类 SpringApplication.run(MemberController.class, args); } } ~~~ 运行main方法,浏览器访问:http://localhost:8080/memberIndex