In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces the Springboot2 integrated druid encryption database password configuration related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this Springboot2 integrated druid encryption database password configuration article will have a harvest, let's take a look.
One: environment
Springboot 2.x
Druid 1.1.21
Two: druid encrypts the database password
Download the druid-1.1.21.jar package locally, run cmd, and enter the command
Java-cp jar package path com.alibaba.druid.filter.config.ConfigTools database password java-cp druid-1.1.21.jar com.alibaba.druid.filter.config.ConfigTools database password
Run successfully output
PrivateKey:MIIBVAIBAD...
PublicKey:MFwwDQYJKo...
Password:PNd/zcG+JEn...
Fill the resulting publicKey and password into the yml configuration file respectively.
Three: single data source
Add dependency
Com.alibaba druid-spring-boot-starter 1.1.21
Yml configuration
Spring: datasource: name: name url: address username: user name password: encrypted password driver-class-name: com.mysql.cj.jdbc.Driver # druid type: com.alibaba.druid.pool.DruidDataSource druid: # Special Tip: configure database encryption config this can not forget filters: stat,wall Config use-global-data-source-stat: true # enable decryption config.decrypt=true Public key: config.decrypt.key connect-properties: druid.stat.mergeSql: true druid.stat.slowSqlMillis: 5000 druid.stat.logSlowSql: true config.decrypt: true config.decrypt.key: public key # configuration information of connection pool # initialization size, minimum number of idle connections Maximum number of active initial-size: 5 min-idle: 5 maxActive: 20 # configure the time to get connection wait timeout maxWait: 60000 # configure how often to detect idle connections that need to be closed, in milliseconds timeBetweenEvictionRunsMillis: 60000 # configure the minimum survival time of a connection in the pool Unit: millisecond minEvictableIdleTimeMillis: 300000 validationQuery: SELECT 1 FROM DUAL testWhileIdle: true testOnBorrow: false testOnReturn: false # Open PSCache and specify the size of the PSCache on each connection poolPreparedStatements: true maxPoolPreparedStatementPerConnectionSize: 20 IV: multiple data sources
Add dependency
Com.alibaba druid-spring-boot-starter 1.1.21 com.baomidou dynamic-datasource-spring-boot-starter 2.5.3
Startup class configuration
@ SpringBootApplication (exclude = DruidDataSourceAutoConfigure.class)
Eg:
Yml configuration
Spring: datasource: dynamic: # default data source primary: CLOUD datasource: CLOUD: url: database address username: user name password: encrypted password driver-class-name: com.mysql.cj.jdbc.Driver druid: public-key: encrypted public key WAREHOUSE: driver-class-name: com.mysql.cj.jdbc.Driver url: database address username: user name password: encrypted password druid: public-key: encrypted public key on "how to configure Springboot2 integrated druid encrypted database password" this article ends here Thank you for reading! I believe that everyone has a certain understanding of the knowledge of "Springboot2 integrated druid encryption database password configuration". If you want to learn more knowledge, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.