用maven创建第一个SpringBoot项目
一、创建maven项目
二、添加springboot的maven依赖
<?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>muyer-springboot</groupId> <artifactId>quickStart</artifactId> <version>1.0-SNAPSHOT</version> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.9.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies> </project>
三、创建相关类和配置文件
1.创建启动类
@SpringBootApplication public class QuickStartpApp { public static void main(String[] args) { SpringApplication.run(QuickStartpApp.class,args); } }
2.创建controller
@RestController public class HelloSpringBoot { @RequestMapping(value = "/hello", method = RequestMethod.GET) public String helloSpringBoot() { return "hello springboot"; } }
3.创建配置文件
server.port=8090
4.类在项目中的结构
四、启动测试
1.点击启动类左边的启动按钮
2.浏览器输入请求地址:http://localhost:8090/hello