当前位置: 首页 > news >正文

教务系统门户网站做网站公司怎么推销

教务系统门户网站,做网站公司怎么推销,wordpress设置新页面跳转,网站备案 途径目录 1.引入相关的依赖 2.nacos的yaml的相关配置&#xff0c;配置密码和相关算法 3.配置数据源连接 3.1 数据库连接配置 4.连接数据库配置类详解&#xff08;DataSourceConfig&#xff09;。 5.完整的配置类代码如下 1.引入相关的依赖 <dependency><groupId>…

目录

1.引入相关的依赖

2.nacos的yaml的相关配置,配置密码和相关算法

3.配置数据源连接

        3.1 数据库连接配置

4.连接数据库配置类详解(DataSourceConfig)。

5.完整的配置类代码如下


1.引入相关的依赖

<dependency><groupId>com.github.ulisesbocchio</groupId><artifactId>jasypt-spring-boot-starter</artifactId><version>3.0.3</version></dependency>

2.nacos的yaml的相关配置,配置密码和相关算法

jasypt:encryptor:algorithm: PBEWithHmacSHA512AndAES_256password: encryptionkey

3.配置数据源连接

        3.1 数据库连接配置

                    使用@ConfigurationProperties(prefix = "spring.datasource")注解的dataSource()方法通过DataSourceBuilder.create().build();创建了一个DataSource的bean。这个bean的配置信息来自于application.propertiesapplication.yml文件中的spring.datasource前缀下的配置项,比如数据库URL、用户名、密码等。

                 重点: 密码在yaml是加密的,如:ENC(N8VBWG5nOHvy5efX3/mlPAmdBykE7iDZFl362LyeaPRXMbLT0PzEIlB/KDXrNYz6),配置了jasypt之后,使用password作为密钥进行加密解密。

#加密
jasypt:encryptor:algorithm: PBEWithHmacSHA512AndAES_256password: encryptionkey
spring:        datasource:driver-class-name: com.mysql.cj.jdbc.Driverjdbc-url: jdbc:mysql://localhost:3306/auth?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&nullCatalogMeansCurrent=trueusername: rootpassword: ENC(N8VBWG5nOHvy5efX3/mlPAmdBykE7iDZFl362LyeaPRXMbLT0PzEIlB/KDXrNYz6)type: com.alibaba.druid.pool.DruidDataSourcedruid:initial-size: 5min-idle: 1max-active: 10max-wait: 60000validation-query: SELECT 1 FROM DUALtest-on-borrow: falsetest-on-return: falsetest-while-idle: truetime-between-eviction-runs-millis: 60000redis:port: 6379
mysql:driver: com.mysql.jdbc.driver

4.连接数据库配置类详解(DataSourceConfig)。

        通过配置类的方式,实现数据库的连接,构建StringEncryptor 的bean对象,实现密码的加密解密,把加密解密串放到配置文件中,用ENC()包裹着,加载配置文件的时候,有ENC()就会自动解密,这样避免配置文件密码泄露的风险。

 @Beanpublic StringEncryptor stringEncryptor() {PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();SimpleStringPBEConfig config = new SimpleStringPBEConfig();config.setPassword("encryptionkey"); // 加密密钥config.setAlgorithm("PBEWithHmacSHA512AndAES_256");config.setKeyObtentionIterations("1000");config.setPoolSize("1");config.setProviderName("SunJCE");config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");config.setStringOutputType("base64");encryptor.setConfig(config);return encryptor;}

5.完整的配置类代码如下

package com.example.auth.config;import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean;
import org.apache.ibatis.session.SqlSessionFactory;
import org.jasypt.encryption.StringEncryptor;
import org.jasypt.encryption.pbe.PooledPBEStringEncryptor;
import org.jasypt.encryption.pbe.config.SimpleStringPBEConfig;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.jdbc.DataSourceBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;import javax.annotation.PostConstruct;
import javax.sql.DataSource;/*** MybatisPlus配置类 数据库连接*/
@Configuration
@MapperScan(basePackages = "com.example.auth.mapper")
public class DataSourceConfig {@Autowiredprivate StringEncryptor stringEncryptor;@ConfigurationProperties(prefix = "spring.datasource")@Beanpublic DataSource dataSource() {return DataSourceBuilder.create().build();}@Beanpublic MybatisPlusInterceptor mybatisPlusInterceptor() {MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();//分页插件interceptor.addInnerInterceptor(new PaginationInnerInterceptor());//注册乐观锁插件interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());return interceptor;}@Beanpublic SqlSessionFactory sqlSessionFactory(DataSource dataSource, MybatisPlusInterceptor interceptor) throws Exception {MybatisSqlSessionFactoryBean ssfb = new MybatisSqlSessionFactoryBean();ssfb.setDataSource(dataSource);ssfb.setPlugins(interceptor);//到哪里找xml文件ssfb.setMapperLocations(new PathMatchingResourcePatternResolver().getResources("classpath:/mapper/*Mapper.xml"));return ssfb.getObject();}@Beanpublic StringEncryptor stringEncryptor() {PooledPBEStringEncryptor encryptor = new PooledPBEStringEncryptor();SimpleStringPBEConfig config = new SimpleStringPBEConfig();config.setPassword("encryptionkey"); // 加密密钥config.setAlgorithm("PBEWithHmacSHA512AndAES_256");config.setKeyObtentionIterations("1000");config.setPoolSize("1");config.setProviderName("SunJCE");config.setSaltGeneratorClassName("org.jasypt.salt.RandomSaltGenerator");config.setStringOutputType("base64");encryptor.setConfig(config);return encryptor;}@PostConstructpublic void init(){/* String  enStr  = stringEncryptor.encrypt("Root@123");String  deSTr  = stringEncryptor.decrypt("N8VBWG5nOHvy5efX3/mlPAmdBykE7iDZFl362LyeaPRXMbLT0PzEIlB/KDXrNYz6");System.out.println("enStr==="+enStr);System.out.println("deSTr==="+deSTr);*/}}

你们的点赞和赞赏,是我继续前进的动力,谢谢。

http://www.yayakq.cn/news/745481/

相关文章:

  • 龙华网站建设专业定制企业做推广可以上那些网站
  • 自己做网站建议冻品网站建设
  • 有口碑的顺德网站建设地产官网怎么做
  • 创建一个网站需要怎么做wordpress优化公司
  • 班级网站开发环境我的网站模板
  • 简单网站php源码下载谷歌竞价广告
  • 烟台网站建设比较大的编程是什么课程内容
  • 团购网站建设费用中国民航机场建设集团网站
  • 景观石网站建设方案wordpress首页修改路径
  • 北京市保障性住房建设中心网站国家信用企业信息系统
  • 东莞网站建设 包装材料小程序打不开什么原因
  • 公司电商网站建设wordpress中文cms主题模板
  • 专业电子网站建设青岛网站建设公
  • 搜关键词可以搜到的网站怎么做fusion做电影网站卡死
  • 免费开通的网站wordpress 卡片式
  • 网站开发记什么科目wordpress老网站重装法
  • 淘宝网站开发要多久合作网站制作
  • 网站如何更换空间建立模板wordpress
  • 公司英文网站多少钱wordpress如何导入
  • 在哪个网站可以找到做国珍的人制作网站的模板免费下载
  • 网站怎样做的高大上建站的cms
  • 免费建立个人网站申请h5做的网站如何连接数据库
  • 更合网站建设制作网app开发
  • 网站需求分析有哪些内容wordpress wti like post
  • 河南建设安全监督网站广州旅游景点
  • 石家庄做网站设计邯郸广告设计招聘
  • dnf卖飞机的网站怎么做的南村网站建设
  • 网站防红链接怎么做的视频号广告推广
  • 网站图片加载优化聊城关键词优化推广
  • 中企动力建站怎么样seo 网站两个ip