這篇文章主要介紹了spring boot基于DRUID實(shí)現(xiàn)數(shù)據(jù)源監(jiān)控過程解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
隨著需求和技術(shù)的日益革新,spring boot框架是越來越流行,她也越來越多地出現(xiàn)在我們的項(xiàng)目中,當(dāng)然最主要的原因還是因?yàn)閟pring boot構(gòu)建項(xiàng)目實(shí)在是太爽了,構(gòu)建方便,開發(fā)簡(jiǎn)單,而且效率高。今天我們并不是來專門學(xué)習(xí)spring boot項(xiàng)目的,我們要講的是數(shù)據(jù)源的加密和監(jiān)控,監(jiān)控到好說,就是不監(jiān)控也沒什么問題,但是數(shù)據(jù)源加密卻涉及到我們的系統(tǒng)安全。
對(duì)于平時(shí)的學(xué)習(xí)測(cè)試,我們?cè)陧?xiàng)目中配置數(shù)據(jù)庫(kù)明文密碼是沒什么問題的,因?yàn)槲覀兊臄?shù)據(jù)不重要,也就無所謂,但是在現(xiàn)實(shí)環(huán)境下的生產(chǎn)平臺(tái),配置明文密碼極有可能會(huì)造成我們數(shù)據(jù)庫(kù)密碼泄露,最終導(dǎo)致我們的生產(chǎn)數(shù)據(jù)泄露,這也就體現(xiàn)了生產(chǎn)環(huán)境數(shù)據(jù)源加密的必要性。下面我們就來看看如何實(shí)現(xiàn)數(shù)據(jù)源加密吧。
創(chuàng)建spring boot項(xiàng)目
創(chuàng)建過程就不贅述了,下面是我的項(xiàng)目依賴:
<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>2.2.1.RELEASE</version> <relativePath/> <!-- lookup parent from repository --> </parent> <groupId>io.githu.syske</groupId> <artifactId>druid-datasouce-decrypt</artifactId> <version>0.0.1-SNAPSHOT</version> <name>druid-datasouce-decrypt</name> <description>Demo project for Spring Boot</description> <properties> <java.version>1.8</java.version> </properties> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <dependency> <groupId>org.mybatis.spring.boot</groupId> <artifactId>mybatis-spring-boot-starter</artifactId> <version>2.1.1</version> </dependency> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <scope>runtime</scope> </dependency> <!-- 阿里巴巴druid --> <dependency> <groupId>com.alibaba</groupId> <artifactId>druid-spring-boot-starter</artifactId> <version>1.1.10</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> <exclusions> <exclusion> <groupId>org.junit.vintage</groupId> <artifactId>junit-vintage-engine</artifactId> </exclusion> </exclusions> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build></project>
新聞熱點(diǎn)
疑難解答
圖片精選