使用spring initializer快速生成SringBoot项目
Hello,SpringBoot
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| package com.nowcoder.community.controller;
import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody;
@Controller @RequestMapping("/alpha") public class AlphaController {
@RequestMapping("/hello") @ResponseBody public String sayHello() { return "Hello, SpringBoot"; } }
|
修改SpringBoot的Tomcat服务器端口
在application.properties中写入:server.port=[端口号]
修改项目访问路径(默认为空)
在application.properties中写入:server.servlet.context-path=[路径]