<!-- mysql驱动 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.20</version> </dependency> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.2.5</version> </dependency>
application.yml 配置共同的参数,并确定当前运行环境
spring:
profiles:
active: dev
这里的spring.profiles.active=dev即表示,当前是dev环境;application-{profile}.yml就对应application-dev.yml,{profile}的取值可以是dev, test, rc, pro
application-dev.yml
server: port: 8050 ############################################################ # # 配置数据源信息 # ############################################################ spring: profiles: dev datasource: # 数据源的相关配置 name: dev type: com.alibaba.druid.pool.DruidDataSource # 使用druid数据源 driver-class-name: com.mysql.cj.jdbc.Driver # mysql驱动 url: jdbc:mysql://127.0.0.1:3406/my_hbl?useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false&serverTimezone=GMT%2B8&useAffectedRows=true&useAffectedRows=true username: root password: Root&123456 filters: stat maxActive: 20 initialSize: 1 maxWait: 60000 minIdle: 1 timeBetweenEvictionRunsMillis: 60000 minEvictableIdleTimeMillis: 300000 validationQuery: select 'x' testWhileIdle: true testOnBorrow: false testOnReturn: false poolPreparedStatements: true maxOpenPreparedStatements: 20