【Mybatis-Plus】02 Spring整合,基本CRUD
创建非骨架普通Maven工程:
引入Spring & MybatisPlus的依赖坐标及其它持久层依赖:
<properties>
<spring.version>5.2.8.RELEASE</spring.version>
</properties> <dependencies> <!-- Junit -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency> <!-- Lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
</dependency> <!-- Jdbc -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.20</version>
</dependency> <!-- Mybatis-Plus -->
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus</artifactId>
<version>3.3.2</version>
</dependency> <!-- log -->
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.12</version>
</dependency> <dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
<version>1.7.30</version>
</dependency> <!-- Spring --> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aspects</artifactId>
<version>${spring.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${spring.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>${spring.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${spring.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${spring.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>${spring.version}</version>
</dependency> <dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${spring.version}</version>
</dependency> <!-- AspectJ -->
<dependency>
<groupId>org.aspectj</groupId>
<artifactId>aspectjweaver</artifactId>
<version>1.9.6</version>
</dependency> </dependencies>
创建一个实体类:
package cn.echo42.pojo; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor; import java.io.Serializable; /**
* @author DaiZhiZhou
* @file MP-Spring
* @create 2020-08-05 22:36
*/ @Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_user")
public class User implements Serializable { private static final long serialVersionUID = 8921929240003713006L; @TableId("user_id")
private Integer user_id;
private String user_name; // @TableField("user_name")
private String user_password; // @TableField("user_password")
private Integer user_status; // @TableField("user_status")
private Integer user_is_del; // @TableField("user_is_del")
}
创建UserMapper接口并继承Maybatis-Plus的BaseMapper接口,同时泛型注入我们User实体类
package cn.echo42.mapper; import cn.echo42.pojo.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; /**
* @author DaiZhiZhou
* @file MP-Spring
* @create 2020-08-05 22:42
*/
public interface UserMapper extends BaseMapper<User> {
}
简单的CRUD可以不需要UserMapper.xml,Maybatis-Plus已经在BaseMapper中帮助我们实现了
有这个传统就默认创建把:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.echo42.mapper.UserMapper">
</mapper>
连接数据库参数配置文件[ db.properties ]:
jdbc.driverClassName = com.mysql.cj.jdbc.Driver
jdbc.url = jdbc:mysql://localhost:3306/oa?serverTimezone=GMT
jdbc.username = root
jdbc.password = 123456
日志配置文件[ log4j.properties ]:
# Global logging configuration
log4j.rootLogger=DEBUG, stdout
# MyBatis logging configuration...
log4j.logger.org.mybatis.example.BlogMapper=TRACE
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n
编写SpringXML的容器配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
"
> <!--
dao层的配置:核心是要产生
Mapper代理类对象
1.引入数据库配置信息
2.数据源配置
3.SqlSessionFactory
4.产生Mapper接口的代理类对象
--> <!-- 1.引入数据库配置信息 -->
<context:property-placeholder location="classpath:db.properties" system-properties-mode="FALLBACK" /> <!--2.数据源配置 -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
</bean> <!-- 3.SqlSessionFactory -->
<bean id="sqlSessionFactory" class="com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="globalConfig" ref="globalConfig" /> <!-- 加载xxMapper.xml -->
<property name="mapperLocations">
<array>
<value>classpath:mapper/*Mapper.xml</value>
</array>
</property> <!-- 配置分页插件 -->
<property name="plugins">
<array>
<bean class="com.baomidou.mybatisplus.extension.plugins.PaginationInterceptor">
</bean>
</array>
</property>
</bean> <!-- 声明全局配置 -->
<bean id="globalConfig" class="com.baomidou.mybatisplus.core.config.GlobalConfig">
<!-- 指定主键自动增长类型 -->
<property name="dbConfig" ref="dbConfig" />
</bean> <bean id="dbConfig" class="com.baomidou.mybatisplus.core.config.GlobalConfig.DbConfig">
<property name="idType" value="AUTO" />
</bean> <!-- 4.产生Mapper接口的代理类对象 -->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 需要生成代理类对象的mapper接口包 -->
<property name="basePackage" value="cn.echo42.mapper" />
<!-- sqlSessionFactory 的name 用于为代理类中生成SqlSession -->
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean>
</beans>
中央容器XML导入Dao配置:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
"
>
<import resource="classpath:bean-xml/dao.xml" />
</beans>
简单的插入测试:
添加操作:
import cn.echo42.mapper.UserMapper;
import cn.echo42.pojo.User;
import org.junit.Test;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; /**
* @author DaiZhiZhou
* @file MP-Spring
* @create 2020-08-05 22:54
*/
public class MybatisPlusTest { @Test
public void SpringIntegrationMP_QuickStart() {
ApplicationContext applicationContext = new ClassPathXmlApplicationContext("classpath:bean-xml/central.xml");
UserMapper userMapper = applicationContext.getBean(UserMapper.class); int insert = userMapper.insert(
new User(
null,
"阿伟001",
"133778",
1,
0
)
); } }
日志打印结果:
DEBUG [main] - Creating a new SqlSession
DEBUG [main] - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@8519cb4] was not registered for synchronization because synchronization is not active
DEBUG [main] - Fetching JDBC Connection from DataSource
DEBUG [main] - Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/oa?serverTimezone=GMT]
DEBUG [main] - JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@495b0487] will not be managed by Spring
DEBUG [main] - ==> Preparing: INSERT INTO sys_user ( user_name, user_password, user_status, user_is_del ) VALUES ( ?, ?, ?, ? )
DEBUG [main] - ==> Parameters: 阿伟001(String), 133778(String), 1(Integer), 0(Integer)
DEBUG [main] - <== Updates: 1
DEBUG [main] - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@8519cb4] Process finished with exit code 0
为了更方便的测试,引入Spring-Test坐标,UserMapper自动装配,全注解测试。
Spring-Test坐标:
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>${spring.version}</version>
</dependency>
测试类:
import cn.echo42.mapper.UserMapper;
import cn.echo42.pojo.User;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; /**
* @author DaiZhiZhou
* @file MP-Spring
* @create 2020-08-05 23:07
*/ @RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "bean-xml/central.xml")
public class MybatisPlusAnnotationTest { @Autowired
UserMapper userMapper; }
这里有个坑,注意xml路径声明要写classpath:,不然Spring读取不到文件了
@ContextConfiguration(locations = "classpath:bean-xml/central.xml")
修改操作:
@Test
public void mpUpdate() { UpdateWrapper<User> updateWrapper = new UpdateWrapper<User>(); updateWrapper.eq("user_id", 6); // WHERE user_id = 6 // updateWrapper.between("id", 10, 20); WHERE id BETWEEN 10 AND 20 int update = userMapper.update(new User(
null,
"杰哥001",
"133778",
1,
0
), updateWrapper); }
他这里的Wrapper对象和SpringDataJPA的条件规范的条件对象极其相似
通过这个对象来注入我们的条件,这个筛选条件的方法几乎一样
修改测试结果:
DEBUG [main] - Creating a new SqlSession
DEBUG [main] - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1787f2a0] was not registered for synchronization because synchronization is not active
DEBUG [main] - Fetching JDBC Connection from DataSource
DEBUG [main] - Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/oa?serverTimezone=GMT]
DEBUG [main] - JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@784b990c] will not be managed by Spring
DEBUG [main] - ==> Preparing: UPDATE sys_user SET user_name=?, user_password=?, user_status=?, user_is_del=? WHERE (user_id = ?)
DEBUG [main] - ==> Parameters: 杰哥001(String), 133778(String), 1(Integer), 0(Integer), 6(Integer)
DEBUG [main] - <== Updates: 1
DEBUG [main] - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1787f2a0]
删除操作:
@Test
public void mpDelete() {
UpdateWrapper<User> updateWrapper = new UpdateWrapper<User>(); updateWrapper.eq("user_id", 6); // WHERE user_id = 6 // updateWrapper.between("id", 10, 20); WHERE id BETWEEN 10 AND 20 int delete = userMapper.delete(updateWrapper);
}
同样的,因为删除只需要筛选条件就够了
日志结果打印:
DEBUG [main] - Creating a new SqlSession
DEBUG [main] - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1787f2a0] was not registered for synchronization because synchronization is not active
DEBUG [main] - Fetching JDBC Connection from DataSource
DEBUG [main] - Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/oa?serverTimezone=GMT]
DEBUG [main] - JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@42f33b5d] will not be managed by Spring
DEBUG [main] - ==> Preparing: DELETE FROM sys_user WHERE (user_id = ?)
DEBUG [main] - ==> Parameters: 6(Integer)
DEBUG [main] - <== Updates: 1
DEBUG [main] - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@1787f2a0]
查询操作:
参数是要求一个序列化接口类型的对象
已知的基本类型的包装类都基本符合此类型,所以小是基本使用的Integer,大到Decimal也可以
@Test
public void mpQuery() {
User user = (User)this.userMapper.selectById(3);
System.out.println(user);
}
因为之前的驼峰转义导致实体类属性命名得更改了:
package cn.echo42.pojo; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor; import java.io.Serializable; /**
* @author DaiZhiZhou
* @file MP-Spring
* @create 2020-08-05 22:36
*/ @Data
@AllArgsConstructor
@NoArgsConstructor
@TableName("sys_user")
public class User implements Serializable { private static final long serialVersionUID = 8921929240003713006L; @TableId("user_id")
private Integer userId; // private Integer user_id; private String userName; // private String user_name; @TableField("user_name") private String userPassword; // private String user_password; @TableField("user_password") private Integer userStatus; // private Integer user_status; @TableField("user_status") private Integer userIsDel; // private Integer user_is_del; @TableField("user_is_del")
}
查询结果:
DEBUG [main] - Creating a new SqlSession
DEBUG [main] - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7d61eb55] was not registered for synchronization because synchronization is not active
DEBUG [main] - Fetching JDBC Connection from DataSource
DEBUG [main] - Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/oa?serverTimezone=GMT]
DEBUG [main] - JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@58ffcbd7] will not be managed by Spring
DEBUG [main] - ==> Preparing: SELECT user_id,user_name,user_password,user_status,user_is_del FROM sys_user WHERE user_id=?
DEBUG [main] - ==> Parameters: 3(Integer)
DEBUG [main] - <== Total: 1
DEBUG [main] - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7d61eb55]
User(userId=3, userName=user02, userPassword=123456, userStatus=1, userIsDel=0)
查询操作2:
通过一个集合对象,装载一系列ID元素注入到这个方法中查询:
@Test
public void mpQuery2() {
List<Serializable> list = new ArrayList<Serializable>();
list.add(2);
list.add(4); List<User> userList = userMapper.selectBatchIds(list); for (User user : userList) {
System.out.println(user);
}
}
查询结果:
DEBUG [main] - Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/oa?serverTimezone=GMT]
DEBUG [main] - JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@2e9fda69] will not be managed by Spring
DEBUG [main] - ==> Preparing: SELECT user_id,user_name,user_password,user_status,user_is_del FROM sys_user WHERE user_id IN ( ? , ? )
DEBUG [main] - ==> Parameters: 2(Integer), 4(Integer)
DEBUG [main] - <== Total: 2
DEBUG [main] - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6c7a164b]
User(userId=2, userName=user01, userPassword=123456, userStatus=1, userIsDel=0)
User(userId=4, userName=user03, userPassword=123456, userStatus=1, userIsDel=0)
查询操作3:
使用Map集合封装筛选条件,Key即字段名称,Value即值
赋值多个条件,表示条件是连接的AND
@Test
public void mpQuery3() {
Map<String, Object> columnMapping = new HashMap<String, Object>(); columnMapping.put("user_is_del", 0);
columnMapping.put("user_password", "123456"); List<User> userList = userMapper.selectByMap(columnMapping); for (User user : userList) {
System.out.println(user);
}
}
查询结果:
DEBUG [main] - Creating a new SqlSession
DEBUG [main] - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6c7a164b] was not registered for synchronization because synchronization is not active
DEBUG [main] - Fetching JDBC Connection from DataSource
DEBUG [main] - Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/oa?serverTimezone=GMT]
DEBUG [main] - JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@c5ee75e] will not be managed by Spring
DEBUG [main] - ==> Preparing: SELECT user_id,user_name,user_password,user_status,user_is_del FROM sys_user WHERE user_password = ? AND user_is_del = ?
DEBUG [main] - ==> Parameters: 123456(String), 0(Integer)
DEBUG [main] - <== Total: 3
DEBUG [main] - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@6c7a164b]
User(userId=2, userName=user01, userPassword=123456, userStatus=1, userIsDel=0)
User(userId=3, userName=user02, userPassword=123456, userStatus=1, userIsDel=0)
User(userId=4, userName=user03, userPassword=123456, userStatus=1, userIsDel=0)
查询操作4:
和上面的增删改一样使用封装条件对象执行:
不过selectCount是用以查询记录数量的
@Test
public void mpQuery4() { QueryWrapper<User> userWrapper = new QueryWrapper<User>(); // 假装这是从控制器传递过来的字符串参数
String fromUrlParam = "user"; userWrapper.like(fromUrlParam != null , "user_name", fromUrlParam); // 用来查询符合筛选条件的记录数量
Integer integer = userMapper.selectCount(userWrapper); System.out.println("return rows : " + integer );
}
查询结果:
DEBUG [main] - Creating a new SqlSession
DEBUG [main] - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@13d9cbf5] was not registered for synchronization because synchronization is not active
DEBUG [main] - Fetching JDBC Connection from DataSource
DEBUG [main] - Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/oa?serverTimezone=GMT]
DEBUG [main] - JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@246f8b8b] will not be managed by Spring
DEBUG [main] - ==> Preparing: SELECT COUNT( 1 ) FROM sys_user WHERE (user_name LIKE ?)
DEBUG [main] - ==> Parameters: %user%(String)
DEBUG [main] - <== Total: 1
DEBUG [main] - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@13d9cbf5]
return rows : 3
查询操作5:
用于分页操作的查询,Mybatis已经帮助我们封装好了页面对象
从这个页面对象中获取信息即可
@Test
public void mpQuery5() { IPage<User> page = new Page<User>(1, 5); userMapper.selectPage(page, null); long total = page.getTotal(); System.out.println("TotalRecords : " + total); List<User> list = page.getRecords(); for (User user : list) {
System.out.println(user);
}
}
查询结果:
DEBUG [main] - Creating a new SqlSession
DEBUG [main] - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@47c81abf] was not registered for synchronization because synchronization is not active
DEBUG [main] - Fetching JDBC Connection from DataSource
DEBUG [main] - Creating new JDBC DriverManager Connection to [jdbc:mysql://localhost:3306/oa?serverTimezone=GMT]
DEBUG [main] - JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@6c25e6c4] will not be managed by Spring
DEBUG [main] - JsqlParserCountOptimize sql=SELECT user_id,user_name,user_password,user_status,user_is_del FROM sys_user
DEBUG [main] - ==> Preparing: SELECT COUNT(1) FROM sys_user
DEBUG [main] - ==> Parameters:
DEBUG [main] - ==> Preparing: SELECT user_id,user_name,user_password,user_status,user_is_del FROM sys_user LIMIT ?,?
DEBUG [main] - ==> Parameters: 0(Long), 5(Long)
DEBUG [main] - <== Total: 5
DEBUG [main] - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@47c81abf]
TotalRecords : 5
User(userId=1, userName=admin, userPassword=admin, userStatus=1, userIsDel=0)
User(userId=2, userName=user01, userPassword=123456, userStatus=1, userIsDel=0)
User(userId=3, userName=user02, userPassword=123456, userStatus=1, userIsDel=0)
User(userId=4, userName=user03, userPassword=123456, userStatus=1, userIsDel=0)
User(userId=5, userName=admin02, userPassword=admin02, userStatus=1, userIsDel=0)
【Mybatis-Plus】02 Spring整合,基本CRUD的更多相关文章
- MyBatis 3与spring整合之使用SqlSession
SqlSessionTemplate是MyBatis-Spring的核心.这个类负责管理MyBatis的SqlSession.调用MyBatis的SQL方法. SqlSessionTemplate是线 ...
- spring,配置文件applictionContext.xml,Mybatis mybatis.xml,springMVC spring整合springMVC mybatis
- Mybatis(使用)与Spring整合
1.总结 https://pan.baidu.com/s/1kWpz7ZD 密码:tsvr 2.代码 https://pan.baidu.com/s/1mjgAeak 密码:h9j8 3.资料 ...
- spring整合mybatis(hibernate)配置
一.Spring整合配置Mybatis spring整合mybatis可以不需要mybatis-config.xml配置文件,直接通过spring配置文件一步到位.一般需要具备如下几个基本配置. 1. ...
- Spring整合Mybatis原理
Spring整合Mybatis原理 目录 Spring整合Mybatis原理 1.@MapperScan注解发挥作用 1.1.导入MapperScannerRegistrar类 1.1.2.执行Imp ...
- spring整合jpa
有点类似SSH整合,O(∩_∩)O哈哈~ <?xml version="1.0" encoding="UTF-8"?> <beans xmln ...
- 分析下为什么spring 整合mybatis后为啥用不上session缓存
因为一直用spring整合了mybatis,所以很少用到mybatis的session缓存. 习惯是本地缓存自己用map写或者引入第三方的本地缓存框架ehcache,Guava 所以提出来纠结下 实验 ...
- 2017年2月16日 分析下为什么spring 整合mybatis后为啥用不上session缓存
因为一直用spring整合了mybatis,所以很少用到mybatis的session缓存. 习惯是本地缓存自己用map写或者引入第三方的本地缓存框架ehcache,Guava 所以提出来纠结下 实验 ...
- Spring整合Mybatis案例,献给初学的朋友
今天我们来学习Spring整合Mybatis. 开发环境:Ide:MyEclipse 2017 CI JDK:1.8 首先我们简单的认识下这两个框架 1.Mybatis MyBatis是一个支持普通S ...
- (转)SpringMVC学习(四)——Spring、MyBatis和SpringMVC的整合
http://blog.csdn.net/yerenyuan_pku/article/details/72231763 之前我整合了Spring和MyBatis这两个框架,不会的可以看我的文章MyBa ...
随机推荐
- 使用nvm安装以及管理多版本node教程
安装nvm.node.npm 下载nvm安装包,推荐使用1.1.7,我个人使用1.1.8会有中文乱码的报错 点击exe文件,注意修改nvm的安装根目录以及node的安装根目录,后者是以后管理多版本no ...
- 铭瑄主板重启后USB3.0失效键盘鼠标无反应需要重新插拔
铭瑄主板重启后USB3.0失效键盘鼠标无反应需要重新插拔 环境: 铭瑄B760 主板,使用鼠标键盘使用USB 3.0 HUB 连接到主板 USB 3.0 口. 重启后,键盘鼠标无反应,需要重新插拔. ...
- 开机启动VM WARE 某台虚拟机
新建一个批处理,内容如下: set vm_root=C:\Program Files (x86)\VMware\VMware Workstation "%vm_root%\vmrun.exe ...
- nomp矿池源码详解
1 项目简介 Node Open Mining Portal(简称NOMP)是一个由Node.js编写的高效.可扩展的加密货币挖矿池软件,专为经验丰富的系统管理员和开发者设计.它包含了Stratum挖 ...
- Lru-k在Rust中的实现及源码解析
LRU-K 是一种缓存淘汰算法,旨在改进传统的LRU(Least Recently Used,最近最少使用)算法的性能.将其中高频的数据达到K次访问移入到另一个队列进行保护. 算法思想 LRU-K中的 ...
- PAT-甲级-1007
一.看题,https://www.patest.cn/contests/pat-a-practise/1007 其实,也是一顿暴力,但是最后一个测试点会运行超时,最开始,计算一段区间的值的总和的时候, ...
- Css实现浏览滚动条效果
Css实现浏览滚动条效果 前言 也是有大半个月没有更新文章了,大部分时间都在玩,然后就是入职的事.今天就更新一个小知识,刷抖音的时候看到的,感觉还不错. 属性介绍 关键属性animation-time ...
- Fake权限验证小例子
前言 关于本地测试如何进行Fake权限验证 正文 在我们使用swagger调试本地接口的时候,我们常常因为每次需要填写token而耽误工作,不可能每次调试的时候都去本地测试环境请求一个token进行验 ...
- Java 集合框架Collection
集合容器主要用于保存对象,主要分类有三种List.Set.Map List有序.可重复的集合 常见的List有ArrayList.Vector.LinkedList等类 Set无序.不可重复 常见Se ...
- TLScanary:Pwn中的利器
TLScanary:Pwn中的利器 引言:什么是TLScanary? 在二进制漏洞利用(Pwn)领域,攻击者面临着层层防护措施的挑战.在安全竞赛(如CTF)和实际漏洞利用中,TLS(线程本地存储) ...