背景:
乙個小需求,單redis服務例項下根據業務配置多個資料庫,需要自定義redis配置稍作改動才能實現,此時就不能redistemplate一步就位了~
注:redis使用單執行緒-多路復用 io模型,別把多業務的併發全加在乙個redis例項上,最好多例項或者集群處理!
基本的配置我就不多說了,可以參考我之前的部落格:springboot 整合 redis 使用詳解
直接上步驟:
中新增引數配置:
redis:
//此處設定多業務對應資料庫
database:
fore: 0
wechat: 1
host: 117.133
.13.74
password: yjyj
port: 6379
timeout: 3000
pool:
max-idle: 30
min-idle: 0
max-wait: -
1
增加自定義配置類:
***
@author
: yuanj
*@date
:2019/2
/1616:
35*/@configuration
@enableautoconfiguration
public
class
redisconfig")
private
int foredatabase;
@value
("$"
)private
int wechatdatabase;
@value
("$"
)private string host;
@value
("$"
)private string password;
@value
("$"
)private
int port;
@value
("$"
)private
int timeout;
@value
("$"
)private
int maxidle;
@value
("$"
)private
int minidle;
@value
("$"
)private
long maxwait;
@bean
public jedispoolconfig getjedispoolconfig()
@bean
(name =
"foreredistemplate"
)public redistemplate getforeredistemplate()
@bean
(name =
"wechatredistemplate"
)public redistemplate getwechatredistemplate()
}
測試:
@restcontroller
public
class
testcontroller
}
注意:上面既可以直接autowire兩個redistemplate,也可以通過redisconfig得到。
Springboot專案中Swagger的使用
2.7.0swagger.version properties io.springfoxgroupid springfox swagger uiartifactid version dependency io.springfoxgroupid springfox swagger2artifactid...
Spring Boot 專案中引入 flyway
org.flywaydb flyway core 5.2.4 flyway spring.flyway.baseline on migrate true spring.flyway.baseline description flyway baseline 禁止刪除 schema 下的 table s...
SpringBoot專案中定製banner
在springboot專案啟動的時候會列印乙個banner,如下圖 而這個banner是可定製的,在resource目錄下建立乙個banner.txt檔案,並在這個檔案裡面寫入想要列印出來的文字。比如 然後將banner.txt檔案複製到spring 專案的resource目錄下,並啟動專案,效果如...