pom问题
<pom.xml>
spring-boot-starter : Spring Boot 场景启动器,Spring Boot将所有的功能场景(模块)抽取出来,做成一个个的starters(启动器),只需项目里引入相关场景的starter, 就会将它所有依赖导入进来。要用什么功能就导入什么场景的启动器。
spring-boot-starter-parent 是当前项目的父级依赖
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.6.RELEASE</version>
</parent>
比如说 tomcat/web/mysql/spring data/ibatis 等等,使用时只<pom.xml>需要引入配置即可使用 ,常见的启动器
https://blog.csdn.net/syilt/article/details/92426474
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-***</artifactId>
</dependency>
引导类
通常有一个名为 *Application 的入口 类,里面定义一个main方法,使用
SpringApplication.run(HelloMailAppliation.class, args); 来启动 SpringBoot 应用项目
@SpringBootApplication 是组合注解
标注在某个类上, 说明这个类是 Spring Boot 的引导类,Spring Boot 就应该运行这个类的main方法来启动 SpringBoot 应用;
配置文件
Spring Boot 使用一个全局配置文件,放置在 src/main/resources 目录或类路径的 /config 下;
application.properties
application.yml(推荐使用yml)
yml 是 YAML(YAML Ain’t Markup Language),是一种语法规则
举例:
server:
port: 8081
contextPath: /hello
user:
name: 张三
password: 123456
通过注解
@Component
@ConfigurationProperties(prefix = “user”)
可以将yml中数据直接注入到对象中