Skip to content

Commit

Permalink
添加数据库多环境,添加mysql阿里云数据库配置
Browse files Browse the repository at this point in the history
  • Loading branch information
caolib committed Jan 23, 2024
1 parent a539849 commit 6c40499
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 18 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
HELP.md
target/

/src/main/resources/application-pro.yml

!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
Expand Down Expand Up @@ -31,5 +33,4 @@ build/
!**/src/test/**/build/

### VS Code ###
.vscode/

.vscode/
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,4 @@ java -jar .\book-1.0.0.RELEASE.jar --server.port=8081
```cmd
java -jar .\book-1.0.0.RELEASE.jar --server.port=8081 --spring.cache.type=none
```

20 changes: 20 additions & 0 deletions src/main/resources/application-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
spring:
config:
activate:
on-profile: dev
# mysql
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/java_design?serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
username: root
password: 123456
type: com.alibaba.druid.pool.DruidDataSource

# redis
data:
redis:
host: localhost
password: 123456
port: 6379
database: 0
timeout: 5000ms
18 changes: 2 additions & 16 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,8 @@ mybatis-plus:
mapper-locations: classpath:mapper/*.xml

spring:
# mysql
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/java_design?serverTimezone=Asia/Shanghai
username: root
password: 123456
type: com.alibaba.druid.pool.DruidDataSource

# redis
data:
redis:
host: localhost
password: 123456
port: 6379
database: 0
timeout: 5000ms
profiles:
active: dev # 可切换为pro,需要修改pro.yml文件相关配置
cache:
type: redis # 不使用改为none
redis:
Expand Down

0 comments on commit 6c40499

Please sign in to comment.