当前位置: 首页 > 编程日记 > 正文

Spring+SpringMVC+Mybatis整合

一、简单测试工程搭建

1、Mybatis所需要的的jar包(包含数据库驱动包和相关的日志包)、SpringMVC和Spring的jar包

2、然后构建一个基本的工程,这里我们使用mapper代理的方式进行Mybatis的编写,关于mapper代理请参考Mybatis简单入门中的Mybatis开发dao方法简介中讲到的mapper代理方式,所以在项目中我们不建立dao包,需要建立mapper包用来存放mapper接口和相应的mapper配置文件。


二、配置Mybatis和Spring整合

1、配置Mybatis的核心配置文件,因为是和Spring整合,所以数据库的配置交给Spring管理由Spring进行数据源的配置。

 1 <?xml version="1.0" encoding="UTF-8" ?>2 <!DOCTYPE configuration3         PUBLIC "-//mybatis.org//DTD Config 3.0//EN"4         "http://mybatis.org/dtd/mybatis-3-config.dtd">5 <configuration>6 7     <typeAliases>8         <!--批量别名定义:Mybatis在定义别名的时候会自动扫描包中的po类,自动的将别名定义为类名(首字母大写或者小写都可以)-->9         <package name="cn.test.ssm.mapper"></package>
10     </typeAliases>
11 
12 </configuration>复制代码

2、下来是Spring和Mybatis的整合,可以参考前面的Mybatis和Spring整合篇中的mapper代理方式。到这里我们就需要配置Spring整合Mybatis的配置文件了,在Spring和Mybatis的整合文件applicationContext-dao.xml配置文件中我们需要配置数据源(dataSource)、会话工厂(sqlSessionFactory)和Mapper扫描器

 1 <?xml version="1.0" encoding="UTF-8"?>2 <beans xmlns="http://www.springframework.org/schema/beans"3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"4        xmlns:context="http://www.springframework.org/schema/context"5        xmlns:aop="http://www.springframework.org/schema/aop"6        xmlns:tx="http://www.springframework.org/schema/tx"7        xsi:schemaLocation="8         http://www.springframework.org/schema/beans9         http://www.springframework.org/schema/beans/spring-beans.xsd
10         http://www.springframework.org/schema/aop
11         http://www.springframework.org/schema/aop/spring-aop.xsd
12         http://www.springframework.org/schema/context
13         http://www.springframework.org/schema/context/spring-context.xsd
14         http://www.springframework.org/schema/tx
15         http://www.springframework.org/schema/tx/spring-tx.xsd">
16 
17 
18     <!--加载数据库信息的配置文件-->
19     <context:property-placeholder location="classpath:db.properties"></context:property-placeholder>
20 
21     <!--配置数据源-->
22     <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
23         <property name="driverClass" value="${jdbc.driver}" />
24         <property name="jdbcUrl" value="${jdbc.url}" />
25         <property name="user" value="${jdbc.username}" />
26         <property name="password" value="${jdbc.password}" />
27     </bean>
28 
29     <!--配置SqlSessionFactory-->
30     <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
31         <!--加载Mybatis的配置文件-->
32         <property name="configLocation" value="classpath:mybatis/sqlMapConfig.xml"></property>
33         <!--配置数据源-->
34         <property name="dataSource" ref="dataSource"></property>
35     </bean>
36 
37     <!--配置mapper扫描器-->
38     <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
39         <property name="basePackage" value="cn.test.ssm.mapper"></property>
40         <property name="sqlSessionTemplateBeanName" value="sqlSessionFactory"></property>
41     </bean>
42 </beans>复制代码

3、接下来我们就开始编写一个简单测mapper测试配置文件,只完成一个小功能(查询一个列表集合) ,在里面使用一些简单的动态sql进行判断避免异常

 1 <?xml version="1.0" encoding="UTF-8" ?>2 <!DOCTYPE mapper3         PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"4         "http://mybatis.org/dtd/mybatis-3-mapper.dtd">5 <!--mapper为根元素,namespace指定了命名空间-->6 <mapper namespace="cn.test.ssm.mapper.ProductDemo">7 8     <!--实现一个简单的列表查询的功能(使用动态sql和sql片段便于扩展,虽然这只是个小的demo并没有做其他的扩展,但是可以养成一种习惯)-->9 
10     <!--sql片段+动态sql-->
11     <sql id="queryListCondition">
12         <where>
13             <if test="productExtend != null">
14                 <if test="productExtend.name != null and productExtend.name != ''">
15                     product.pname LIKE '%${productExtend.name}%'
16                 </if>
17             </if>
18         </where>
19     </sql>
20 
21     <!--为了便于扩展,使用ProductExtent类作为输出映射,这样除了可以查询Product之外还可以扩展其他的字段-->
22     <select id="findProductListByName" parameterType="cn.test.ssm.po.ProductQueryVo" resultType="cn.test.ssm.po.ProductExtend">
23         SELECT product.* FROM product
24         <where>
25             <include refid="queryListCondition"></include>
26         </where>
27     </select>
28 </mapper>复制代码

4、写完mapper配置文件之后就写一个接单的接口程序,其中只包含一个方法就是查询列表信息。

 1 package cn.test.ssm.mapper;2 3 import cn.test.ssm.po.ProductExtend;4 import cn.test.ssm.po.ProductQueryVo;5 6 import java.util.List;7 8 public interface ProductDemo {9 
10     public List<ProductExtend> findProductListByName(ProductQueryVo productQueryVo) throws Exception;
11 }复制代码

三、配置Spring和Service层整合

1、一般情况下都是定义service接口和对应的实现类,这里我们也定义一个简单的ProductService接口和其实现类作为service层的主要类

①Product Service接口:主要就是要调用mapper接口中定义的那一个查询列表的方法

 1 package cn.test.ssm.service;2 3 import cn.test.ssm.po.ProductExtend;4 import cn.test.ssm.po.ProductQueryVo;5 6 import java.util.List;7 8 public interface ProductService {9     public List<ProductExtend> findProductListByName(ProductQueryVo productQueryVo) throws Exception;
10 }复制代码

②ProductServiceImpl实现类,实现上面接口中的方法,由于要和Mybatis和Spring已经整合(采用mapper代理的方式),并且在applicationContext-dao配置文件中配置了mapper扫描器,所以我们可以使用注解的方式注入Mapper接口然后在service中调用接口中的方法

 1 package cn.test.ssm.service.impl;2 3 import cn.test.ssm.mapper.ProductDemo;4 import cn.test.ssm.po.ProductExtend;5 import cn.test.ssm.po.ProductQueryVo;6 import cn.test.ssm.service.ProductService;7 import org.springframework.beans.factory.annotation.Autowired;8 9 import java.util.List;
10 
11 public class ProductServiceImpl implements ProductService {
12 
13     @Autowired
14     private ProductDemo productDemo;  //自动注入mapper接口,然后在实现service的方法中调用mapper接口中的方法
15 
16     @Override
17     public List<ProductExtend> findProductListByName(ProductQueryVo productQueryVo) throws Exception {
18         return productDemo.findProductListByName(productQueryVo);
19     }
20 }复制代码

2、上面写好了接口和实现类,然后就是将service交给Spring进行管理,配置applicationContext-service.xml对service进行整合。对service整合主要包括:service本身接口实现类的bean配置、事务控制等

①管理service本身的接口实现类的bean

 1 <?xml version="1.0" encoding="UTF-8"?>2 <beans xmlns="http://www.springframework.org/schema/beans"3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"4        xmlns:context="http://www.springframework.org/schema/context"5        xmlns:aop="http://www.springframework.org/schema/aop"6        xmlns:tx="http://www.springframework.org/schema/tx"7        xsi:schemaLocation="8         http://www.springframework.org/schema/beans9         http://www.springframework.org/schema/beans/spring-beans.xsd
10         http://www.springframework.org/schema/aop
11         http://www.springframework.org/schema/aop/spring-aop.xsd
12         http://www.springframework.org/schema/context
13         http://www.springframework.org/schema/context/spring-context.xsd
14         http://www.springframework.org/schema/tx
15         http://www.springframework.org/schema/tx/spring-tx.xsd">
16 
17     <!--对service本身的接口实现类的bean配置-->
18     <bean id="productService" class="cn.test.ssm.service.impl.ProductServiceImpl">
19 
20     </bean>
21 
22 </beans>复制代码

②进行事务控制的配置

 1 <?xml version="1.0" encoding="UTF-8"?>2 <beans xmlns="http://www.springframework.org/schema/beans"3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"4        xmlns:context="http://www.springframework.org/schema/context"5        xmlns:aop="http://www.springframework.org/schema/aop"6        xmlns:tx="http://www.springframework.org/schema/tx"7        xsi:schemaLocation="8         http://www.springframework.org/schema/beans9         http://www.springframework.org/schema/beans/spring-beans.xsd
10         http://www.springframework.org/schema/aop
11         http://www.springframework.org/schema/aop/spring-aop.xsd
12         http://www.springframework.org/schema/context
13         http://www.springframework.org/schema/context/spring-context.xsd
14         http://www.springframework.org/schema/tx
15         http://www.springframework.org/schema/tx/spring-tx.xsd">
16 
17     <!--
18         事务控制的配置
19         对数据库操作Mybatis的事务控制使用spring的jdbc事务管理控制类
20     -->
21 
22     <!--事务管理器-->
23     <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
24         <!--添加对数据源的控制-->
25         <property name="dataSource" ref="dataSource"></property>
26     </bean>
27 
28     <!--通知-->
29     <tx:advice id="txAdvice">
30         <tx:attributes>
31             <!--配置传播行为-->
32             <!--配置必须进行事务控制的方法-->
33             <tx:method name="save*" propagation="REQUIRED"/>
34             <tx:method name="delete*" propagation="REQUIRED"></tx:method>
35             <tx:method name="insert*" propagation="REQUIRED"></tx:method>
36             <tx:method name="update*" propagation="REQUIRED"></tx:method>
37             <!--配置支持事务的方法-->
38             <tx:method name="find*" propagation="SUPPORTS" read-only="true"></tx:method>
39         </tx:attributes>
40     </tx:advice>
41 
42     <!--配置aop去调用通知-->
43     <aop:config>
44         <aop:advisor advice-ref="txAdvice" pointcut="execution(* cn.test.ssm.service.impl.*.*(..))"></aop:advisor>
45     </aop:config>
46 </beans>复制代码

四、配置整合springmvc和spring

1、首先配置springmvc的配置文件,其中包括处理器映射器、处理器适配器、视图解析器的配置和对controller层包自动扫描的配置

 1 <?xml version="1.0" encoding="UTF-8"?>2 <beans xmlns="http://www.springframework.org/schema/beans"3        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"4        xmlns:context="http://www.springframework.org/schema/context"5        xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"6        xsi:schemaLocation="http://www.springframework.org/schema/beans7         http://www.springframework.org/schema/beans/spring-beans-3.2.xsd8         http://www.springframework.org/schema/mvc9         http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
10         http://www.springframework.org/schema/context
11         http://www.springframework.org/schema/context/spring-context-3.2.xsd
12         http://www.springframework.org/schema/aop
13         http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
14         http://www.springframework.org/schema/tx
15         http://www.springframework.org/schema/tx/spring-tx-3.2.xsd ">
16 
17 
18     <!--配置controller的扫描-->
19     <context:component-scan base-package="cn.test.ssm.controller"></context:component-scan>
20 
21     <!--配置mvc:annotation代替基于注解方式的处理器映射器和适配器的配置-->
22     <mvc:annotation-driven></mvc:annotation-driven>
23 
24     <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"></bean>
25 </beans>复制代码

2、下来在web.xml中配置springmvc的前端控制器,里面主要包括DispatcherServlet的配置以及springmvc配置文件的路径配置。

 1 <?xml version="1.0" encoding="UTF-8"?>2 <web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"3          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"4          xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"5          version="4.0">6     <!--配置前端控制器-->7     <servlet>8         <servlet-name>SpringMvc</servlet-name>9         <servlet-class>
10             org.springframework.web.servlet.DispatcherServlet
11         </servlet-class>
12         <!--
13             配饰SpringMVC的配置文件(处理器映射器、适配器等)
14             注明需要这样配置的原因:自己配置contextConfigLocation,就不会自己默认加载/WEB-INF/下面的dispatch-servlet.xml
15         -->
16         <init-param>
17             <param-name>contextConfigLocation</param-name>
18             <param-value>classpath:spring/applicationContext-springmvc.xml</param-value>
19         </init-param>
20     </servlet>
21     <servlet-mapping>
22         <servlet-name>SpringMvc</servlet-name>
23         <url-pattern>*.do</url-pattern>
24     </servlet-mapping>
25 </web-app>复制代码

五、在controller层写handler程序

这里实现的功能也比较简单,由于只是为了测试整个整合流程的正确,所以依旧是按照查询列表进行编写,然后从service调用方法,返回模型视图、

 1 package cn.test.ssm.controller;2 3 import cn.test.ssm.po.ProductExtend;4 import cn.test.ssm.service.ProductService;5 import org.springframework.beans.factory.annotation.Autowired;6 import org.springframework.stereotype.Controller;7 import org.springframework.web.bind.annotation.RequestMapping;8 import org.springframework.web.servlet.ModelAndView;9 
10 import java.util.List;
11 
12 @Controller
13 public class ProductController {
14 
15     @Autowired
16     private ProductService productService;
17 
18     @RequestMapping("/queryList.do")
19     public ModelAndView queryList() throws Exception{
20 
21         //从service层调用方法
22         List<ProductExtend> productExtendList = productService.findProductListByName(null);
23 
24         //返回ModelandView
25         ModelAndView modelAndView = new ModelAndView();
26         modelAndView.addObject(productExtendList);
27         modelAndView.setViewName("/WEB-INF/items/itemsList.jsp");
28 
29         return modelAndView;
30     }
31 }复制代码

六、配置Spring容器

到这里,我们还需要配置spring容器的监听和相应配置文件(applicationContext-dao.xml......)的加载。在配置文件中我们需要在IDEA中修改class文件的输出路径(本来默认是自动建立out文件,然后将class文件输出进去),参考这篇文章。至此,所有的配置都已经完成,下面就开始测试

1     <!--配置spring容器的监听器-->
2     <context-param>
3         <param-name>contextConfigLocation</param-name>
4         <param-value>/WEB-INF/classes/spring/applicationContext-*.xml</param-value>
5     </context-param>
6     <listener>
7         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
8     </listener>复制代码

七、使用简单的jsp视图进行测试

1、数据库中的Product表信息:

1 CREATE TABLE `product` (
2   `pid` INT(11) NOT NULL AUTO_INCREMENT,
3   `pname` VARCHAR(255) DEFAULT NULL,
4   `shop_price` DOUBLE DEFAULT NULL,
5   PRIMARY KEY (`pid`)
6 ) ENGINE=INNODB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8复制代码

2、然后在浏览器中输入http://localhost:8080/TestSSM2/queryList.do测试得到下面的结果信息


转载于:https://juejin.im/post/5ce24a5ce51d4510595d90d7

相关文章:

【Tools】Markdown数学符号公式(史上最全公式表)

Markdown数学符号&公式 文章目录Markdown数学符号&公式1. 希腊字母表2. 希腊字母3. 数学符号表4. 数学符号5. 数学符号补充表6. 数学符号补充1. 希腊字母表 符号代码符号代码α\alphaα\alphaA\AlphaA\Alphaβ\betaβ\betaB\BetaB\Betaγ\gammaγ\gammaΓ\GammaΓ\gam…

Editplus下载、安装并最佳配色方案(强烈推荐)

不多说&#xff0c;直接上干货&#xff01; Editplus下载 第一步&#xff1a;进入官网 https://www.editplus.com/ 第二步&#xff1a;下载 https://www.editplus.com/download.html Editplus安装 我这里&#xff0c;直接以一个压缩包来安装&#xff0c;需要的&#xff0c;请…

MySQL数据库开发规范-EC

最近一段时间一边在线上抓取SQL来优化&#xff0c;一边在整理这个开发规范&#xff0c;尽量减少新的问题SQL进入生产库。今天也是对公司的开发做了一次培训&#xff0c;PPT就不放上来了&#xff0c;里面有十来个生产SQL的案例。因为规范大部分还是具有通用性&#xff0c;所以也…

操作系统与内存管理

操作系统内存管理 文章目录操作系统内存管理1. 虚拟地址空间2. 内存地址空间含义及分配3. 虚拟内存诞生的前世与今生&#xff1f;3.1 内存管理的好处3.2 **内存管理实现总体策略**4. 不同进程如何划分内存地址空间&#xff1f;5 内存分配与回收5.1 buffer和cache5.2 malloc背后…

圆形 LBP 特征

template <typename _Tp> staticinline void elbp_(InputArray _src, OutputArray _dst,int radius, int neighbors) {// 得到数据矩阵Mat src _src.getMat();// 输出矩阵_dst.create(src.rows-2*radius, src.cols-2*radius, CV_32SC1);Mat dst _dst.getMat();// 初始化…

40个Java多线程问题总结

&#xff08;转&#xff09; 这篇文章作者写的真是不错 40个问题汇总 1、多线程有什么用&#xff1f; 一个可能在很多人看来很扯淡的一个问题&#xff1a;我会用多线程就好了&#xff0c;还管它有什么用&#xff1f;在我看来&#xff0c;这个回答更扯淡。所谓"知其然知其所…

SLAM十四讲笔记1

文章目录ch02 初识SLAMch02-01 经典视觉SLAM框架ch02-02 SLAM问题的数学表述ch03 三维空间刚体运动ch03.01 旋转矩阵&#xff1a;点和向量,坐标系01 向量a在线性空间的基[e1,e2,e3][e_1,e_2,e_3][e1​,e2​,e3​]下的坐标为[a1,a2,a3]T[a_1,a_2,a_3]^T[a1​,a2​,a3​]T.02 向量…

12、OpenCV实现图像的空间滤波——图像平滑

1、空间滤波基础概念 1、空间滤波基础 空间滤波一词中滤波取自数字信号处理&#xff0c;指接受或拒绝一定的频率成分&#xff0c;但是空间滤波学习内容实际上和通过傅里叶变换实现的频域的滤波是等效的&#xff0c;故而也称为滤波。空间滤波主要直接基于领域&#xff08;空间域…

计算 LBP 特征

#include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/features2d/features2d.hpp> #include <opencv2/features2d/features2d.hpp> // 计算原始LBP特征 cv::Mat OLBP(cv::Mat& srcImage) {const int nRows …

三维重建【四】-------------------结构光 三维重建----论文调研

1. 动态目标实时三维重建-结构光方案 动态目标 三维重建 Stripe boundary codes for real-time structured-light range scanning of moving objects 我们提出了一种新的实时结构光扫描方法。在分析现有结构光技术的基本假设之后&#xff0c;我们基于编码投影条纹之间的边界&…

APP开发定制

app是什么意思? APP&#xff0c;application的简称&#xff0c;是智能手机的第三方应用程序&#xff0c;常见的有微信、手机qq、今日头条、手机支付宝、腾讯视频、微店等&#xff0c;随着智能手机和ipad等移动终端设备的普及&#xff0c;人们逐渐习惯了使用APP客户端上网的方式…

Haar 特征提取

double HaarExtract(double const ** image ,int type_, cv::Rect roi) {double value;double wh1, wh2;double bk1, bk2;int x roi.x;int y roi.y;int width roi.width;int height roi.height;switch (type_){// Haar水平边缘case 0: // HaarHEdgewh1 calcIntegral(image…

awk的基本⽤法

awk的基本⽤法 awk是报告⽣成器&#xff0c;格式化⽂本输出&#xff0c;有多种版本。centos中的是gawk即GNU awk版本。 awk⼯作原理&#xff1a;第⼀步&#xff1a;执⾏BEGIN{action;...}语句块中的语句。第⼆步&#xff1a;从⽂件或标准输⼊&#xff08;stdin&#xff09;读取…

视音频数据处理入门:RGB、YUV像素数据处理【转】

转自&#xff1a;http://blog.csdn.net/leixiaohua1020/article/details/50534150 视音频数据处理入门系列文章&#xff1a; 视音频数据处理入门&#xff1a;RGB、YUV像素数据处理 视音频数据处理入门&#xff1a;PCM音频采样数据处理 视音频数据处理入门&#xff1a;H.264视频…

SVO(SVO: fast semi-direct monocular visual odometry)

SVO&#xff08;SVO: fast semi-direct monocular visual odometry&#xff09;翻译 文章目录SVO&#xff08;SVO: fast semi-direct monocular visual odometry&#xff09;翻译1、介绍2、系统概述3、符号4、运动估计4.1、 基于稀疏模型的图像对齐4.2、 通过特征对齐松弛4.3、…

MSER 候选车牌区域检测

#include "opencv2/highgui/highgui.hpp" #include "opencv2/features2d/features2d.hpp" #include "opencv2/imgproc/imgproc.hpp" #include <iostream> // Mser车牌目标检测 std::vector<cv::Rect> mserGetPlate(cv::Mat srcImage…

从HelloWorld看Knative Serving代码实现

为什么80%的码农都做不了架构师&#xff1f;>>> 摘要&#xff1a; Knative Serving以Kubernetes和Istio为基础&#xff0c;支持无服务器应用程序和函数的部署并提供服务。我们从部署一个HelloWorld示例入手来分析Knative Serving的代码细节。 概念先知 官方给出的这…

svo_note

SVO论文笔记1.frame overviews2. Motion Estimate Thread2.1 Sparse Model-based Image Alignment 基于稀疏点亮度的位姿预估2.2 Relaxation Through Feature Alignment 基于图块的特征点匹配2.3 Pose and Structure Refinement3 Mapping Thread3.1 depth-filter3.2 初始化参考…

Druid 配置 wallfilter

这个文档提供基于Spring的各种配置方式 使用缺省配置的WallFilter <bean id"dataSource" class"com.alibaba.druid.pool.DruidDataSource" init-method"init" destroy-method"close">...<property name"filters" v…

vue下的bootstrap table + jquery treegrid, treegrid无法渲染的问题

在mian.js导入的包如下&#xff1a;该bootstrap-table-treegrid.js需要去下载&#xff0c;在复制到jquery-treegrid/js/ 1 import $ from jquery 2 import bootstrap/dist/css/bootstrap.min.css 3 import bootstrap/dist/js/bootstrap.min 4 import bootstrap-table/dist/boot…

内存和缓存的区别

今天看书的时候又看到了内存和缓存&#xff0c;之所以说又&#xff0c;是因为之前遇到过查过资料&#xff0c;但是现在又忘了(图侵删)。 所以又复习一遍&#xff0c;记录一下&#xff0c;有所纰漏的地方&#xff0c;欢迎指正。 同志们&#xff0c;上图并不是内存和缓存中的任何…

【Boost】noncopyable:不可拷贝

【CSDN】&#xff1a;boost::noncopyable解析 【Effective C】&#xff1a;条款06_若不想使用编译器自动生成地函数&#xff0c;就该明确拒绝 1.example boost::noncopyable 为什么要boost::noncopyable 在c中定义一个类的时候&#xff0c;如果不明确定义拷贝构造函数和拷贝赋…

BigData NoSQL —— ApsaraDB HBase数据存储与分析平台概览

一、引言时间到了2019年&#xff0c;数据库也发展到了一个新的拐点&#xff0c;有三个明显的趋势&#xff1a; 越来越多的数据库会做云原生(CloudNative)&#xff0c;会不断利用新的硬件及云本身的优势打造CloudNative数据库&#xff0c;国内以阿里云的Cloud HBase、POLARDB为代…

ubuntu clion 创建桌面快捷方式

ubuntu clion 创建桌面快捷方式 首先在终端下输入 cd /usr/share/applications/进入applications目录下&#xff0c;建立一个clion.desktop文件 sudo touch clion.desktop然后在vim命令下编辑该文件 sudo vim clion.desktop进入vim后&#xff0c;按i插入开始编辑该文件&…

Flex 布局:语法篇

2019独角兽企业重金招聘Python工程师标准>>> 布局的传统解决方案&#xff0c;基于盒状模型&#xff0c;依赖 display 属性 position 属性 float 属性。它对于那些特殊布局非常不方便&#xff0c;比如&#xff0c;垂直居中就不容易实现。 2009年&#xff0c;W3C 提…

特征运动点估计

cv::Mat getRansacMat(const std::vector<cv::DMatch>& matches, const std::vector<cv::KeyPoint>& keypoints1, const std::vector<cv::KeyPoint>& keypoints2, std::vector<cv::DMatch>& outMatches) {// 转换特征点格式std::vecto…

Vue+Element-ui+二级联动封装组件

通过父子组件传值 父组件&#xff1a; 1 <template>2 <linkage :citysList"citysList" :holder"holder" saveId"saveId"></linkage>3 </template>4 <script>5 import linkage from ./common/linkage6 export de…

MOG2 成员函数参数设定

pMOG2->setDetectShadows(true); // 背景模型影响帧数 默认为500 pMOG2->setHistory(1000); // 模型匹配阈值 pMOG2->setVarThreshold(50); // 阴影阈值 pMOG2->setShadowThreshold(0.7);前景中模型参数&#xff0c;设置为0表示背景&#xff0c;255为前景&#xff…

webpack 大法好 ---- 基础概念与配置(1)

再一次见面&#xff01; Light 还是太太太懒了&#xff0c;距离上一篇没啥营养的文章已经过去好多天。今天为大家介绍介绍 webpack 最基本的概念&#xff0c;以及简单的配置&#xff0c;让你能快速得搭建一个可用的 webpack 开发环境。 webpack的安装 webpack 运行于 node 环境…

Zookeeper迁移(扩容/缩容)

zookeeper选举原理在迁移前有必要了解zookeeper的选举原理&#xff0c;以便更科学的迁移。快速选举FastLeaderElectionzookeeper默认使用快速选举&#xff0c;在此重点了解快速选举&#xff1a;向集群中的其他zookeeper建立连接&#xff0c;并且只有myid比对方大的连接才会被接…