1.server.pom引入springboot相关依赖
(1) spring-boot-starter-web:springboot web开发核心包.
(2) spring-boot-starter-actuator:健康检查,很多性能监控的组件都是依赖此包开发.
(3) spring-boot-configuration-processor:配置文件依赖,方便我们做实体类和配置文件的映射.
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
</dependencies>
2.编写主启动类
package com.ccm.server.user;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
/**
* @Description server-user服务启动类
* @Author zhouzhiwu
* @CreateTime 2020/07/03 14:04
*/
@SpringBootApplication
public class ServerUserApplication {
public static void main(String[] args) {
SpringApplication.run(ServerUserApplication.class,args);
}
}
3.编写application.yml
server:
port: 1000 #服务端口
spring:
application:
name: server-user #服务名称
4.测试
启动成功并且application.yml中的配置生效.