1.SpringBoot创建
- 添加依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>
- 在父包中创建启动程序
package com.qf.sb2103;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
//启动程序
@SpringBootApplication
public class SpringBoot2103Application {
public static void main(String[] args) {
SpringApplication.run(SpringBoot2103Application.class,args);
}
}
【说明】启动程序最好创建在父包中
-
配置文件(注意格式)
server: port: 8081
默认的配置文件的名字只能是application.properties/yml/yaml
配置服务端口号