4.0.0commybatis_demo20.0.1-SNAPSHOTmybatis_demo2Demo project for Spring Boot1.8UTF-8UTF-82.3.7.RELEASEorg.springframework.bootspring-boot-starter-weborg.mybatis.spring.bootmybatis-spring-boot-starter2.1.4mysqlmysql-connector-javaruntimeorg.projectlomboklomboktrueorg.springframework.bootspring-boot-starter-testtestorg.junit.vintagejunit-vintage-enginejunitjunittestcom.github.pagehelperpagehelper5.2.0log4jlog4j1.2.17org.springframework.bootspring-boot-dependencies${spring-boot.version}pomimportorg.apache.maven.pluginsmaven-compiler-plugin3.8.11.8
1.8UTF-8org.springframework.bootspring-boot-maven-plugin2.3.7.RELEASEcom.mybatis_demo2.MybatisDemo2Applicationrepackagerepackage
package com.mybatis_demo2.mapper;
import com.github.pagehelper.Page;
import com.mybatis_demo2.pojo.User;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author lv
* @date 2022年11月12日17点24分
* dao层,主要负责和数据库交互
*/
public interface UserMapper {
/**
* 查询所有用户信息
* @return
*/
public List selectUserAll();
/**
* 查询单个用户
* @param id
* @return
*/
public User selectOneUser(int id);
/**
* 添加数据
* @param user
* @return
*/
public int adduser(User user);
/**
* 更新数据
* @param user
* @return
*/
public int update(User user);
/**
* 删除数据
* @param id
* @return
*/
public int del(Integer id);
/**
* 查询分页总条数(普通分页方式)
* @return
*/
Long countAllUser();
/**
* 查询每页的显示数据(普通分页方式)
* @param index LIMIT函数的起始索引值
* @param size LIMIT函数的每页大小
* @return
*/
List selectPageUser(@Param("index") int index, @Param("size") int size);
/**
* 使用分页插件实现分页查询
* @return
*/
Page pagePluginselectUser();
/**
* 查询单个用户(根据用户名查询,演示SQL注入)
* @param username
* @return
*/
User findUsernameUser(String username);
/**
* 据id查询用户(使用标签,在UserMapper.xml中使用where和if标签)
* @param id
* @return
*/
List findUserList(int id);
/**
* 根据username查询用户(使用标签,在UserMapper.xml中使用where,if和 foreach 标签)
* @Param("unamelist") 定义参数名,方便UserMapper.xml找到参数
* @param unamelist
* @return
*/
List findUserListByUsername(@Param("unamelist") List unamelist);
}
4.创建UserMapper.xml
注意在resources资源文件夹下创建com\mybatis_demo2\mapper目录
insert into users(username,password,nickname,addtime) values(#{username},#{password},#{nickname},NOW())
update users set username=#{username} where id=#{id}
delete from users where id=#{id}
spring JMS对于异步消息处理基本上只需配置下就能进行高效的处理。其核心就是消息侦听器容器,常用的类就是DefaultMessageListenerContainer。该容器可配置侦听器的并发数量,以及配合MessageListenerAdapter使用消息驱动POJO进行消息处理。且消息驱动POJO是放入TaskExecutor中进行处理,进一步提高性能,减少侦听器的阻塞。具体配置如下:
ZIP文件的解压缩实质上就是从输入流中读取数据。Java.util.zip包提供了类ZipInputStream来读取ZIP文件,下面的代码段创建了一个输入流来读取ZIP格式的文件;
ZipInputStream in = new ZipInputStream(new FileInputStream(zipFileName));
&n
Spring可以通过注解@Transactional来为业务逻辑层的方法(调用DAO完成持久化动作)添加事务能力,如下是@Transactional注解的定义:
/*
* Copyright 2002-2010 the original author or authors.
*
* Licensed under the Apache License, Version
使用nginx lua已经两三个月了,项目接开发完毕了,这几天准备上线并且跟高德地图对接。回顾下来lua在项目中占得必中还是比较大的,跟PHP的占比差不多持平了,因此在开发中遇到一些问题备忘一下 1:content_by_lua中代码容量有限制,一般不要写太多代码,正常编写代码一般在100行左右(具体容量没有细心测哈哈,在4kb左右),如果超出了则重启nginx的时候会报 too long pa
import java.util.Stack;
public class ReverseStackRecursive {
/**
* Q 66.颠倒栈。
* 题目:用递归颠倒一个栈。例如输入栈{1,2,3,4,5},1在栈顶。
* 颠倒之后的栈为{5,4,3,2,1},5处在栈顶。
*1. Pop the top element
*2. Revers
仅作笔记使用
public class VectorQueue {
private final Vector<VectorItem> queue;
private class VectorItem {
private final Object item;
private final int quantity;
public VectorI