SpringBoot工程快速搭建
Maven配置:pom.xml
<!--所有的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>
<!--web 功能起步的依赖-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!--启动热部署-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
引导入口:com.zxl.SpringbootApplication.java
// 声明该类是一个springboot的引导类
@SpringBootApplication
public class MyApplication {
//main方法是Java程序的入口
public static void main(String[] args) {
// run方法表示运行springboot的引导类,参数就是springboot引导类的字节码对象
SpringApplication.run(MyApplication.class);
}
}
controller层示例:com.zxl.controller.Controller.java
@Controller
public class QuickController {
@RequestMapping("/quick")
@ResponseBody
public String quick() {
return "你啊123qweqw world";
}
}
resource下覆盖配置(第一种):application.properties
用自己的配置替换默认配置
#服务器的端口号
server.port=8081
#当前web应用的名称
server.servlet.context-path=/demo
resource下覆盖配置(第二种):application.yml
server:
port: 8082
servlet:
context-path: /demo