新建project——》选择左侧栏 Spring Initializr,
选择依赖:
pom.xml 中的 spring-boot-maven-plugin 插件 有可能没指定版本,此时在下面加上 < version>
org.springframework.boot
spring-boot-maven-plugin
${project.parent.version}
properties 和 yml 两种格式的配置文件都是可以的,也就是 application.yml 也是 OK 的!
my.url=http://imooc.com
my.name=imooc
my:url: http://imooc.comname: imooc
两种格式转换网站:https://toyaml.com/index.html
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/test?useSSL=false&characterEncoding=utf8&allowPublicKeyRetrieval=true
spring.datasource.username=root
spring.datasource.password=123456
@Value("${school.age}")
public void setAge(Integer age) {this.age = age;
}