1、Spring Boot默认配置文件为application.properties或application.yml(这里用的是application.yml,所以要注意空格),例如配置名“:”后面有空格或空行
server:
# 配置端口
port: 8080
# 配置项目发布路径
servlet:
context-path: /
# 使用jpa操纵mysql数据库
# 需要添加依赖spring-boot-starter-data-jpa和mysql-connector-java
spring:
datasource:
url: jdbc:mysql://localhost:3306/blog?useUnicode=true&useSSL=false&characterEncoding=utf-8&autoReconnect=true
username: root
password: yuan0123
driver-class-name: com.mysql.jdbc.Driver
jpa:
database: MYSQL
show-sql: true
hibernate:
ddl-auto: update
# 设置运行模式,加载不同配置文件application-*.yml,以便适应各种运行环境
profiles:
# 模式设置-开发模式-自动加载application-dev.yml
# active: dev
# 模式设置-测试模式-自动加载application-test.yml
active: test
#logging:
# 日志默认配置文件:classpath:logback-spring.xml/classpath:logback-spring.groovy,也可以用以下字段自定义配置
#config: classpat