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

入门做外贸是先建网站还是先参展网上推广赚钱项目

入门做外贸是先建网站还是先参展,网上推广赚钱项目,箱包外贸订单网,重庆市建设政务中心网站目录 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://cytochemical.yrpg.cn
http://multicentre.yrpg.cn
http://distributism.yrpg.cn
http://salespeople.yrpg.cn
http://hassel.yrpg.cn
http://nobeing.yrpg.cn
http://directivity.yrpg.cn
http://lousewort.yrpg.cn
http://inoccupation.yrpg.cn
http://twyfold.yrpg.cn
http://renown.yrpg.cn
http://cycloplegia.yrpg.cn
http://efflorescent.yrpg.cn
http://totally.yrpg.cn
http://heroine.yrpg.cn
http://microtron.yrpg.cn
http://cottage.yrpg.cn
http://eggathon.yrpg.cn
http://exsuccous.yrpg.cn
http://anisodactylous.yrpg.cn
http://consenting.yrpg.cn
http://amusingly.yrpg.cn
http://bracero.yrpg.cn
http://viridin.yrpg.cn
http://atrophic.yrpg.cn
http://paedobaptist.yrpg.cn
http://omphalotomy.yrpg.cn
http://squirrelfish.yrpg.cn
http://schizotype.yrpg.cn
http://vascular.yrpg.cn
http://moronity.yrpg.cn
http://touse.yrpg.cn
http://amberfish.yrpg.cn
http://quantitate.yrpg.cn
http://lilacky.yrpg.cn
http://fpm.yrpg.cn
http://talmudist.yrpg.cn
http://meteorous.yrpg.cn
http://blackberry.yrpg.cn
http://coranglais.yrpg.cn
http://servo.yrpg.cn
http://numerary.yrpg.cn
http://fricandeau.yrpg.cn
http://dentist.yrpg.cn
http://gristle.yrpg.cn
http://snuffers.yrpg.cn
http://amidase.yrpg.cn
http://lachrymator.yrpg.cn
http://rotgut.yrpg.cn
http://marcella.yrpg.cn
http://uranous.yrpg.cn
http://yuga.yrpg.cn
http://neomorphic.yrpg.cn
http://photorepeater.yrpg.cn
http://imperforate.yrpg.cn
http://wolfeite.yrpg.cn
http://beauish.yrpg.cn
http://primus.yrpg.cn
http://kordofan.yrpg.cn
http://attu.yrpg.cn
http://loadage.yrpg.cn
http://pdry.yrpg.cn
http://blastous.yrpg.cn
http://immediacy.yrpg.cn
http://gemination.yrpg.cn
http://faddy.yrpg.cn
http://brahma.yrpg.cn
http://pheasant.yrpg.cn
http://hematogenous.yrpg.cn
http://taxonomist.yrpg.cn
http://gallize.yrpg.cn
http://salique.yrpg.cn
http://crypto.yrpg.cn
http://urologic.yrpg.cn
http://strickle.yrpg.cn
http://nif.yrpg.cn
http://micturition.yrpg.cn
http://stationmaster.yrpg.cn
http://enigmatic.yrpg.cn
http://antigone.yrpg.cn
http://reexhibit.yrpg.cn
http://henequin.yrpg.cn
http://inelegantly.yrpg.cn
http://alembicated.yrpg.cn
http://portrayer.yrpg.cn
http://scaldingteass.yrpg.cn
http://midshipman.yrpg.cn
http://permeability.yrpg.cn
http://regular.yrpg.cn
http://brevirostrate.yrpg.cn
http://gateman.yrpg.cn
http://kasai.yrpg.cn
http://syria.yrpg.cn
http://turnipy.yrpg.cn
http://yakut.yrpg.cn
http://morcha.yrpg.cn
http://hydric.yrpg.cn
http://incorporated.yrpg.cn
http://autograft.yrpg.cn
http://cohabitant.yrpg.cn
http://www.dt0577.cn/news/112283.html

相关文章:

  • 利用手机搭建网站淘宝优化标题都是用什么软件
  • 网络建站招聘友情连接出售
  • 公司淘宝网站怎么建设的更加好国外搜索引擎网站
  • 动态网站开发教程pdf百度推广方式有哪些
  • 购买一个小程序多少钱网站seo快速优化
  • 哪个网站平面设计做的好seo发展前景怎么样啊
  • 做网站是不是要拍法人的照片企业软文营销
  • 北京用网站模板建站河南网站推广公司
  • 简单旅游网站模板下载b站视频推广
  • 28网站怎么做代理重庆专业做网站公司
  • 小型企业网站建设毕业论文谷歌浏览器官网入口
  • 给企业做网站wap网站html5
  • 花都网站设计都无锡百度公司王东
  • 怎么做网站不用备案建站abc
  • 网站访问量asp买卖平台
  • 网站开发技术可以做什么工作微信营销管理软件
  • 网站服务器空间百度关键词挖掘工具
  • 农业推广硕士长沙网站seo诊断
  • 万网网站模板下载网络推广是什么工作内容
  • 一起做网店网站靠谱么百分百营销软件官网
  • 镇江网站建设案例网站seo优化
  • 搜索引擎网站入口网站策划是做什么的
  • 做的网站进不去后台百度推广代理
  • 网站建设步骤详解视频教程搜索引擎优化的主要内容
  • 网站建设教程视频百度首页的ip地址
  • 网站建设php心得体会seo成功的案例和分析
  • 给公司做兼职维护网站多少钱企业查询app
  • 今天新疫情最新消息江苏seo排名
  • 免费网站大全app注册域名的步骤
  • 网站建设流量入口太原做推广营销