springboot搭建 RESTful 网站应用
一、POM文件添加依赖(在文一中已配置的可跳过)
<!--springMvc-->
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId>
</dependency>
二、yml配置文件(properties文件同下)
常用属性
server.port=8081 //设定http监听端口,默认为8080
server.servlet-path= //设定dispatcher servlet的监听路径,默认为: /
参考 xixicat SpringBoot配置属性之Server
三、创建Controller(controller包与springboot启动类同级)
路径:src.main.java.域名反写.项目名.controller
@RestController
public class IndexController{@RequestMapping("/hello/{name}")public String hello(@PathVariable String name){return "Hello World!" + name;}
}
四、启动项目并访问