SpringBoot快速入门
1.1
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.taojunrui</groupId> <artifactId>springboot_demo</artifactId> <version>1.0-SNAPSHOT</version> <!--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> <dependencies> <!--SpringBoot要集成SpringMVC进行Controller的开发,所以项目要导入web的启动依赖--> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> </project>
1.3
package com.taojunrui; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; //要通过SpringBoot提供的引导类起步SpringBoot才可以进行访问 @SpringBootApplication public class MySpringBootApplication { public static void main(String[] args) { SpringApplication.run(MySpringBootApplication.class); } }
package com.taojunrui.com.taojunrui.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; //在引导类MySpringBootApplication同级包或者子级包中创建QuickStartController @Controller public class QuickStartController { @RequestMapping("/quick") @ResponseBody public String quick(){ return "springboot 访问成功!"; } }
tomcat已经起步,端口监听8080




浙公网安备 33010602011771号