spring 配置文件学习

springboot配置文件严格按照树形结构来配置,不然很容易出错。。。。重点。
1:配置多个数据源

1.1:读取数据源

spring:                     spring:
  profiles:                    profiles:
    active: sit   或者           active: dev

2:application.yml文件

server:           
  port: 8081                  --配置端口号
  servlet:
    context-path: /springboot --配置访问项目的前缀

连接数据库

datasource:
  driver-class-name: com.mysql.jdbc.Driver    --数据库驱动
  url: jdbc:mysql://127.0.0.1:3306/boy        --连接地址
  username: root                              --用户名
  password: admin                             --密码
jpa:
  hibernate :
    ddl-auto : update                   -- create(代表每次启动项目都会删除原来的表,重新创建,会删除数据),update不会
  show-sql: true                              --打印sql语句
@Entity                                 --对应数据库实体
public class Boy {

    @Id                                 --id自增长
    @GeneratedValue
    private  Integer id;}

待续。。。

猜你喜欢

转载自blog.csdn.net/qq_32722783/article/details/81331170