mybatis3简单入门 - 1

1.Mybatis入门 Mybatis入门+jdbc了解+数据库连接池(共享单车)+lombok(简化java开发) 阅读详情
  1. 使用到的mysql语句;
  2. mybatis 日志配置;
  3. mybatis CRUD简单操作

1. 使用到的mysql语句

本次我们使用的是mysql数据库进行mybatis简单的crud操作,对于mysql的操作,我们自然可以使用Navicat进行图形化的操作,这里给出我用到的语句;

Mysql 数据类型:支持多种类型,大致可以分为三类:数值、日期/时间和字符串(字符)类型。具体可以参考:

Mysql数据类型:菜鸟教程-Mysql数据类型

--建库
CREATE DATABASE test;
--建表
CREATE TABLE IF NOT EXISTS student(
   stu_id INT AUTO_INCREMENT,
   stu_name VARCHAR(20) NOT NULL,
   stu_age int,
   stu_score double,
   PRIMARY KEY ( stu_id )
)ENGINE=InnoDB DEFAULT CHARSET=utf8;
--可能会遇到的语句
--修改字段属性
ALTER TABLE student CHANGE stu_name VARCHAR(30);
--增加字段名称
ALTER TABLE student ADD COLUMN class_id int(4);
--字段重命名
ALTER TABLE student CHANGE score stu_score DOUBLE NOT NULL;

注解:

AUTO_INCREMENT : 每一个表只能由一个AUTO_INCREMENT列, 告知Mysql本列每当增加一行时,自动增量。从而该列可以作为主键值。如果一列被指定为AUTO_INCREMENT,如果我们使用INSERT语句插入了一个新值(唯一的),那么下一次增量就在这个值的基础上进行递增;

常见的Mysql引擎: mysql的引擎在我们对表进行操作时,都是通过mysql的引擎来完成的,常见的mysql引擎:

InnoDB: 事务处理引擎,不支持全文本搜索;

MyISAM:性能较高的引擎,支持全文本搜索,但是不支持事物;

MEMORY: 功能等同于MyISAM,但是由于数据库存储在内存(不是磁盘中)速度较快;


2. Mybatis 日志配置

2.1 首先我们回顾下java主流的日志框架:本文采用:common-logging + log4j

Java 日志框架:细说JAVA主流的日志工具库

2.2 Mybatis 的内置日志工厂提供日志功能,内置日志工厂将日志交给以下其中一种工具作代理:

  • SLF4J
  • Apache Commons Logging
  • Log4j 2
  • Log4j
  • JDK logging

MyBatis 内置日志工厂基于运行时自省机制选择合适的日志工具。它会使用第一个查找得到的工具(按上文列举的顺序查找)。如果一个都未找到,日志功能就会被禁用。

如果想使用其它日志工具,你可以通过在 MyBatis 配置文件 mybatis-config.xml 里面添加一项 setting 来选择别的日志工具。

<configuration>
  <settings>
    ...
    <setting name="logImpl" value="LOG4J"/>
    ...
  </settings>
</configuration>

logImpl 可选的值有:SLF4J、LOG4J、LOG4J2、JDK_LOGGING、COMMONS_LOGGING、STDOUT_LOGGING、NO_LOGGING

2.3 根据自己的mapper.xml映射文件中的命名空间值来配置mybatis日志

mapper.xml

<mapper namespace="com.mybatis3.dao.mapper">
  <select id="selectStudent" resultType="com.mybatis3.model.Student">
    select * from student where id = #{id}
  </select>
</mapper>

log4j.properties文件:

# 全局日志配置
log4j.rootLogger=ERROR, stdout

# MyBatis 日志配置...
log4j.logger.com.mybatis3.dao.mapper=TRACE

# 控制台输出...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n


3. Mybatis简单的CRUD操作


3.1 数据库表结构:


3.2 项目结构:

项目代码展示:

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>com.qian</groupId>
  <artifactId>mybatis</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <packaging>jar</packaging>

  <name>mybatis</name>
  <url>http://maven.apache.org</url>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>

  <dependencies>
    <dependency>
	    <groupId>junit</groupId>
	    <artifactId>junit</artifactId>
	    <version>4.12</version>
	    <scope>test</scope>
	</dependency>
	
	<dependency>
	    <groupId>org.mybatis</groupId>
	    <artifactId>mybatis</artifactId>
	    <version>3.4.6</version>
	</dependency>
	
	<dependency>
	    <groupId>mysql</groupId>
	    <artifactId>mysql-connector-java</artifactId>
	    <version>8.0.11</version>
	</dependency>
	
	<!-- <dependency>
      	<groupId>org.slf4j</groupId>
      	<artifactId>slf4j-api</artifactId>
      	<version>1.7.5</version>
    </dependency>

    <dependency>
	      <groupId>org.slf4j</groupId>
	      <artifactId>slf4j-log4j12</artifactId>
	      <version>1.7.12</version>
    </dependency> -->
	<dependency>
	  <groupId>commons-logging</groupId>
	  <artifactId>commons-logging</artifactId>
	  <version>1.2</version>
	</dependency>
    <dependency>
	      <groupId>log4j</groupId>
	      <artifactId>log4j</artifactId>
	      <version>1.2.17</version>
	</dependency>
  </dependencies>
</project>

model层

Student就是一个简单的JAVA BEAN对象,只是增加了几个简单的构造方法和重写了toString()方法;

dao层以及mapper.xml文件

IStudentDao.java

public interface IStudentDao {
	//增
	public int insertStudent(Student student);
	//删
	public boolean deleteStudentById(int id);
	//改
	public boolean updateStudent(Student student);
	//查
	public Student selectStudentById(int id);
	public List<Student> selectAllStudents();
	public List<Student> selectStudentByName(String name);
	public Map<String, Student> selectStudentToMap(String mapKey);
	public List<Student> selectAllStudentsByConditions(String name,int ageStart, int ageEnd);
}

StudentMapper.xml

<?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="com.mybatis3.dao.mapper">
	<!-- 解决字段冲突问题:主要是针对由返回结果的也就是insert语句 -->
	<!-- 解决方式1: 使用别名 select stu_name name, -->
	<!-- 解决方式2: restultMap查询结果行的映射处理:字段和属性不一致问题
		数据库表student(stu_id,stu_name,stu_age,score)
		javabean中的student[id, name, age, score] -->
	<resultMap type="com.mybatis3.model.Student" id="studentResultMapper">
		<id column="stu_id" property="id"/>
		<result column="stu_name" property="name"/>
		<result column="stu_age" property="age"/>
	</resultMap>
	
	<insert id="insertStudent" parameterType="com.mybatis3.model.Student">
		insert into student(stu_name,stu_age,score)
		values(#{name},#{age},#{score}) 
                <!--返回刚插入的这条记录的id-->
		<selectKey keyProperty="id" resultType="int">
			select @@identity
			<!-- select last_insert_id(); -->
		</selectKey>
	</insert>
	
	<delete id="deleteStudentById">
		<!-- 此处#{id}仅仅是一个占位符 -->
		delete from student where stu_id = #{id};
	</delete>
	
	<update id="updateStudent" parameterType="com.mybatis3.model.Student">
		update student set stu_name=#{name}, stu_age=#{age}, score=#{score} 
		where stu_id=#{id}
	</update>
	
	<!-- resultType将 id name age score自动转成Student
		并非指最终结果集的类型而是指将查询出来DB中的每一条记录的字段封装成的类型 -->
	<select id="selectStudentById" resultType="com.mybatis3.model.Student">
		<!-- 使用别名解决字段冲突问题 -->
		select stu_id id, stu_name name, stu_age age, score from student where stu_id=#{id};
	</select>
        
        <select id="selectAllStudents" resultType="com.mybatis3.model.Student" resultMap="studentResultMapper">
		select stu_id, stu_name, stu_age, score from student
	</select>
	
        <!-- 模糊查询字符串拼接问题 -->
	<select id="selectStudentByName" resultType="com.mybatis3.model.Student" resultMap="studentResultMapper">
		<!-- #{xxx}为占位符:mybatis会进行动态拼接,使用的是PreparedStatement的setParameter来设置参数 -->
		select stu_id, stu_name, stu_age, score from student where stu_name like '%' #{name} '%'
		<!-- 为第一种的正式写法 -->
		<!-- select id, name, age, score from student where name like concat('%' #{name} '%') -->
		<!-- ${value}为字符串拼接:mybatis会进行硬编码拼接,使用的是Statement: sql注入,没有预编译效率低下 只能是value -->
		<!-- select id, name, age, score from student where name like '%${value}%' -->
	</select>
	<select id="selectStudentToMap" resultType="com.mybatis3.model.Student" resultMap="studentResultMapper">
		select stu_id, stu_name, stu_age, score from student
	</select>
	
	<!-- 传递多个参数,#{参数map的key} -->
	<select id="selectAllStudentsByConditions" resultType="com.mybatis3.model.Student" resultMap="studentResultMapper">
		select stu_id, stu_name, stu_age, score 
		from student 
		where stu_name like '%' #{name} '%' 
		and stu_age between #{ageStart} and #{ageEnd}
	</select>
	
</mapper>
mybatis3.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">

<configuration>
	
	
	<!-- 注册属性文件位置和 属性的值 -->	
        <!--  在 properties 元素体内<properties>指定的属性首先被读取。
             然后根据 properties 元素中的 resource 属性读取类路径下属性文件或根据 url 属性指定的路径读取属性文件,并覆盖已读取的同名属性。
   	 最后读取作为方法参数传递的属性,并覆盖已读取的同名属性。
	因此,通过方法参数传递的属性具有最高优先级,resource/url 属性中指定的配置文件次之,最低优先级的是 properties 属性中指定的属性。 -->
	
	<properties resource="db-mysql/mysql.properties">
		<!-- 开启为占位符指定一个默认值特性和三元排队特性 -->
		<property name="org.apache.ibatis.parsing.PropertyParser.enable-default-value" value="true"/>	
		<!-- 过 properties 元素的子元素来传递 -->
		<property name="dbname" value="test"/>
	</properties>
	
	<settings>
		<setting name="logImpl" value="LOG4J"/>
	</settings>
	
	<environments default="jdbc">
		<environment id="jdbc">
			<!-- Mybatis支持两种事物:JDBC MANAGED(使用容器来管理事物例如spring) -->
			<transactionManager type="JDBC"/>		
			<dataSource type="POOLED">
				<property name="driver" value="${jdbc.driver}"/>
				<!-- 使用properties中指定的属性值,优先权最低 -->
				<property name="url" value="${jdbc.url}${dbname}"/>
				<property name="username" value="${jdbc.username}"/>
				<property name="password" value="${jdbc.password}"/>
			</dataSource>
		</environment>
	</environments>
	
	<!-- 注册映射文件位置 MyBatis到哪里去找到这些定义 SQL 映射语句 -->
	<mappers>
		<!-- RESOURCE: 使用相对于类路径的资源引用 -->
		<mapper resource="com/mybatis3/dao/StudentMapper.xml"/>
		
		<!-- URL: 使用完全限定资源定位符(URL)
		<mapper url="file:///var/mappers/StudentMappper.xml"/>
		
		CLASS: 值为dao接口的全名:需要满足如下三个条件
		(1) 映射文件的名字和dao层接口的名字一样 也就是映射文件名字为IStudentDao.xml;
		(2) 映射文件放到dao层包下
		(3) 在映射文件下<mapper namespace="com.mybatis3.dao.IStudent">
		<mapper class="com.mybatis3.dao.IStudentDao"/>
		
		PACKAGE:将包内的映射器接口实现全部注册为映射器
		<package name="com.mybatis3.dao"/>
		-->
	</mappers>
</configuration>

SqlSessionUtil.java

主要是用于获取SqlSession和关闭SqlSession

package com.mybatis3.dao.utils;

import java.io.IOException;
import java.io.InputStream;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

public class SqlSessionUtil {
	// 线程安全 的 重量级对象,与数据库一一对应,所以一个应用由一个对象就可以,
	private static SqlSessionFactory sqlSessionFactory = null;
	/*SqlSession对象是对应于数据库的一次会话,一次会话以sqlsession创建开始,以close关闭;
	 *SqlSession对应于一次会话,所以它是线程不安全的,所以用时创建,用完马上关闭,关闭时它会检测事物是否
	 *提交,如果提交就直接关闭,如果没有提交就会回归 
	*/
	
	static{
		//获取sqlSession: 读取配置文件--> SqlSessionFactoryBuilder -> sqlSessionFactory -> sqlSession
		String resource = "mybatis3.xml";
		InputStream inputstream;
		SqlSessionFactoryBuilder sqlSessionFactoryBuilder =null;
		try {
			inputstream = Resources.getResourceAsStream(resource);
			sqlSessionFactoryBuilder = new SqlSessionFactoryBuilder();
			sqlSessionFactory = sqlSessionFactoryBuilder.build(inputstream);
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			//builder主要是用来创建Factory对象,只要创建完factory对象它就可以销毁,所以可以将它放到一个方法内;
			if(sqlSessionFactoryBuilder!=null){
				sqlSessionFactoryBuilder = null;
			}
		}		
	}
	
	public static SqlSession getSqlSession(){
		if(sqlSessionFactory!=null){
			return sqlSessionFactory.openSession();			
		}
		return null;
	}
	
	public static SqlSession getSqlSession(boolean autoCommit){
		if(sqlSessionFactory!=null){
			return sqlSessionFactory.openSession(autoCommit);			
		}
		return null;
	}
	
	public static void closeSqlSession(SqlSession sqlSession){
		if(sqlSession!= null){
			sqlSession.close();
		}
	}
}

StudentDao.java

package com.mybatis3.dao;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.SqlSession;
import com.mybatis3.dao.utils.SqlSessionUtil;
import com.mybatis3.model.Student;

public class StudentDao implements IStudentDao {

	private SqlSession sqlSession = null;
	
	public int insertStudent(Student student) {
		try{
			sqlSession = SqlSessionUtil.getSqlSession();
			sqlSession.insert("insertStudent",student);
			sqlSession.commit();
		}finally{
			SqlSessionUtil.closeSqlSession(sqlSession);						
		}
		return student.getId();
	}

	public boolean deleteStudentById(int id) {
		try{
			sqlSession = SqlSessionUtil.getSqlSession();
			int resultCol = sqlSession.delete("deleteStudentById", id);
			sqlSession.commit();
			if(resultCol > 0){
				return true;
			}
		}finally{
			SqlSessionUtil.closeSqlSession(sqlSession);						
		}
		return false;
	}

	public boolean updateStudent(Student student) {
		try{
			sqlSession = SqlSessionUtil.getSqlSession();
			int resultCol = sqlSession.update("updateStudent", student);
			sqlSession.commit();
			if(resultCol > 0){
				return true;
			}
		}finally{
			SqlSessionUtil.closeSqlSession(sqlSession);						
		}
		return false;
	}

	public Student selectStudentById(int id) {
		try{
			sqlSession = SqlSessionUtil.getSqlSession();
			Student student = sqlSession.selectOne("selectStudentById", id);
			return student;
		}finally{
			SqlSessionUtil.closeSqlSession(sqlSession);						
		}
	}

	public List<Student> selectAllStudents() {
		try{
			sqlSession = SqlSessionUtil.getSqlSession();
			return sqlSession.selectList("selectAllStudents");
		}finally{
			SqlSessionUtil.closeSqlSession(sqlSession);						
		}		
	}

	public List<Student> selectStudentByName(String name) {
		try{
			sqlSession = SqlSessionUtil.getSqlSession();
			return sqlSession.selectList("selectStudentByName", name);
		}finally{
			SqlSessionUtil.closeSqlSession(sqlSession);						
		}
	}
	/**
	 * @param mapKey: 查询出的map所需要使用的key,这个key为数据库的字段名,也是最终每条map记录的key值
	 * 				      若数据库中mapKey的值不唯一,后面的结果会把前面的结果覆盖掉;
	 */
	public Map<String, Student> selectStudentToMap(String mapKey) {
		try{
			sqlSession = SqlSessionUtil.getSqlSession();
			return sqlSession.selectMap("selectStudentToMap", mapKey);
		}finally{
			SqlSessionUtil.closeSqlSession(sqlSession);						
		}
	}

	public List<Student> selectAllStudentsByConditions(String name, int ageStart, int ageEnd) {
		try{
			//sqlSession.listXXX方法中没有传入一个数组的方法,所有只能封装成集合
			Map<String, Object> paramMap = new HashMap<String, Object>();
			paramMap.put("name", name);
			paramMap.put("ageStart", ageStart);
			paramMap.put("ageEnd", ageEnd);
			sqlSession = SqlSessionUtil.getSqlSession();
			return sqlSession.selectList("selectAllStudentsByConditions",paramMap);
		}finally{
			SqlSessionUtil.closeSqlSession(sqlSession);						
		}
	}

}

StudentService.java

serviec层,调用dao层的代码

package com.mybatis3.service;

import java.util.List;
import java.util.Map;

import com.mybatis3.dao.IStudentDao;
import com.mybatis3.model.Student;

public class StudentService implements IStudentService {
	private IStudentDao studentDao;
	
	public int addStudent(Student student) {
		return studentDao.insertStudent(student);
	}

	public boolean removeStudentById(int id){
		return studentDao.deleteStudentById(id);
	}
	
	//改
	public boolean modifyStudent(Student student){
		return studentDao.updateStudent(student);
	}
	//查
	public Student findStudentById(int id){
		return studentDao.selectStudentById(id);
	}
	
	public List<Student> findAllStudents(){
		return studentDao.selectAllStudents();
	}
	
	public List<Student> findStudentByName(String name){
		return studentDao.selectStudentByName(name);
	}
	
	public Map<String, Student> findStudentToMap(String mapKey){
		return studentDao.selectStudentToMap(mapKey);
	}
		
	public IStudentDao getStudentDao() {
		return studentDao;
	}
	
	public void setStudentDao(IStudentDao studentDao) {
		this.studentDao = studentDao;
	}

	public List<Student> findAllStudents(String name, int ageStart, int ageEnd) {
		return studentDao.selectAllStudentsByConditions(name, ageStart, ageEnd);
	}
}

StudentTest.java

测试类

package com.qian.mybatis;

import java.util.List;
import java.util.Map;

import org.junit.Before;
import org.junit.Test;

import com.mybatis3.dao.StudentDao;
import com.mybatis3.model.Student;
import com.mybatis3.service.StudentService;

public class StudentTest {
	
	private StudentService studentService=null;
	
	@Before
	public void before(){
		studentService = new StudentService();
		studentService.setStudentDao(new StudentDao());		
	}
	
	@Test
	public void testInsert(){
		Student student = new Student();
		student.setName("张三");
		student.setAge(27);
		student.setScore(95.5);
		int id = studentService.addStudent(student);
		System.out.println("id = "+id);
	}
	
	@Test
	public void testDelete(){
		boolean result = studentService.removeStudentById(6);
		System.out.println(result);
	}
	
	@Test
	public void testUpdate(){
		Student student = new Student("LISI",23,99.9);
		student.setId(11);
		boolean result = studentService.modifyStudent(student);
		System.out.println(result);
	}
	
	@Test
	public void testFindStudentById(){
		Student student = studentService.findStudentById(11);
		System.out.println(student);
	}
	@Test
	public void testFindAllStudents(){
		List<Student> students = studentService.findAllStudents();
		System.out.println(students);
	}
	
	@Test
	public void testFindStudentByName(){
		List<Student> students = studentService.findStudentByName("李四");
		System.out.println(students);
	}
	
	@Test
	public void testFindStudentToMap(){
		Map<String,Student> students = studentService.findStudentToMap("name");
		System.out.println(students);
	}
	
	@Test
	public void testFindAllStudents2(){
		List<Student> students = studentService.findAllStudents("张三", 22, 35);
		System.out.println(students);
	}
}

参考文献:

【1】:mybatis3官网参考文档

【2】:bjpowernodeMybatis教程

























Mybatis Plus 3.0 快速入门 (简称 MP)是一个MyBatis的增强工具,在 MyBatis 的基础上只做增强不做改变,为简化开发、提高效率而生。 阅读详情

相关推荐

Windows系统下Mamba环境配置实战:从零到编译成功

本文详细记录了在Windows系统下从零开始配置Mamba深度学习环境的完整实战过程。针对官方不直接支持Windows的难点,文章提供了关键解决方案,包括安装特定版本的Python、PyTorch与第三方Triton,以及修改源码以解决Windows编译器的兼容性问题,最终成功编译并运行Mamba-SSM。

weixin_28842269的博客 499

MyBatis3——入门介绍

MyBatis——入门介绍

代码星辰的博客 2027

Qwen-Image LoRA训练实战:从数据准备到异常修复的全流程解析

本文详细解析了Qwen-Image LoRA训练的全流程,从数据准备到参数优化再到异常修复。通过实战案例展示了如何利用LoRA技术微调Qwen-Image模型,提升中文场景下的图像生成质量,特别针对手脚生成异常等问题提供了有效解决方案。文章还分享了中文提示词优化技巧和高级训练方法,帮助开发者高效训练出高质量的LoRA模型。

lemon的博客 965

Mybatis3详解 之 MyBatis 基础

MyBatis本是Apache的一个开源项目iBatis,2010年这个项目由Apache Software Foundation迁移到了Google Code,并且改名为MyBatis,也就是从3.0版本开始 iBatis改名为MyBatis。

IT小郭的技术博客 1333

搜索神器Perplexity的详细使用方法(持续更新)

本文主要介绍了ChatGPT的互补工具Perplexity的详细使用方法,希望对新手有所帮助。需要说明的是,Perplexity不需要上网工具,很方便新手和小白上手使用。Perplexity的官网链接为:https://www.perplexity.ai/ 。 文章目录 1. 为什么要讲Perplexity? 2. 详细使用方法 2.1 使用要点一 2.2 使用要点二 2.3 使用要点三

herosunly的博客 8万+

AndroidKiller之APK 编译失败,无法继续下一步签名【BUG解决】【App反向解析】

文章目录项目场景:问题描述原因分析:解决方案:BUG解决 项目场景: AndroidKiller: 在反向解析APP包时报错:APK 编译失败,无法继续下一步签名。 网上很多方法都是无效的哈,我追究原因发现,这个bug的出现大部分情况都是因为Apktool的问题。 此方法:百分之百解决此bug! 错误如下: 问题描述 APK 编译失败,无法继续下一步签名! 原因分析: Apktool版本不适配的问题,现在的技术更新换代太快,我们安装AndroidKiller的时候,有时候不是官方渠道的话,他的版本是非常

一键难忘的博客 2万+

Mybatis3 快速入门

摘录百度百科的内容:MyBatis 是一款优秀的持久层框架,它支持定制化 SQL、存储过程以及高级映射。MyBatis 避免了几乎所有的 JDBC 代码和手动设置参数以及获取结果集。MyBatis 可以使用简单的 XML 或注解来配置和映射原生信息,将接口和 Java 的 POJOs(Plain Old Java Objects,普通的 Java对象)映射成数据库中的记录如果 Hibernate 是自动化持久层框架,那么 Mybatis 就是半自动化持久层框架。半自动???听起来好像 lower 了。

qq_43505188的博客 434

道路施工检测 (construction) - 基于Mapillary Vistas数据集的YOLOv11目标检测及UI界面实现

目标检测是计算机视觉的重要任务,目标是识别图像中的目标物体类别及其位置(用边界框表示)。两阶段检测器:如Faster R-CNN,准确度高但速度较慢单阶段检测器:如YOLO系列、SSD,速度快且精度相对较好,适合实时场景数据量:约25,000张高分辨率街景图标注类型:语义分割、实例分割、多类别检测类别示例:construction, road, car, person, traffic sign等格式:COCO风格JSON标注。

YOLO 496

Mybatis3全面详解

Mybatis3 1. MyBatis的介绍 (1) MyBatis的历史 原是Apache的一个开源项目,iBatis,2010年6月这个项目由Apache Software Foundation 迁移到了 Goodle Code,随着开发团队转投Google code旗下,iBatis3.X正式更名为MyBatis,代码于2013年11月迁移到Github。 iBatis 一词 来源于 internet 和 abatis的组合。是一个基于Java的持久层框架。iBatis提供的持久层框架包括Sql M

想看什么文章都可以私信给我,综合性博客。 3196

UniRx之基本语法格式

想要更好的去学习UniRx,我们最好是先理解UniRx 的语法格式。就像我们去学习英语或者汉语一样,理解了基本的语法规则后,再学其他的就信手拈来了。

TxNet 924

SAP CAP 编程模型简介

官网 CAP 是用于构建企业级服务和应用程序的语言、库和工具框架。它引导开发人员沿着经过验证的最佳实践和大量现成的解决方案来应对重复性任务的“黄金之路”。 基于 CAP 的项目受益于对领域的主要关注。我们没有深入研究过于技术性的学科,而是专注于在快速变化的云技术世界中加速开发和保护投资。 CAP 框架融合了经过验证和广泛采用的开源和 SAP 技术,如下图所示。 在开源技术之上,CAP主要增加了: 核心数据服务 (CDS) 作为我们用于域模型和服务定义的通用建模语言。 用于 Node.js 和 Ja

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1544

MyBatis_3

MyBatis_3 一、MyBatis相关的配置文件 1.1.MyBatis的核心配置文件 1.1.1.名称–我们可以自己定义,推荐大家使用【mybatis-config.xml】 1.1.2.位置 IntelliJ IDEA中通过Maven创建项目,一般都保存在src/main/resources目录下。 1.1.3.文件中的配置元素及其属性 例如: <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE configuration

CBXdm的博客 218

突破Cloudflare 5秒盾:TLS指纹伪装+Playwright行为模拟,爬虫存活率从35%提至78%

TLS指纹精准识别:Cloudflare会解析客户端的TLS Client Hello包(如SSL版本、密码套件、扩展字段),Python的requests/urllib库的TLS指纹是“黑名单级”,请求一出即被拦截;行为特征检测:静态的浏览器伪装(如User-Agent)已失效,Cloudflare会监控页面加载后的行为(是否有鼠标移动、滚动、点击,行为是否机械);JS环境深度验证:通过WebGL、Canvas、字体渲染、Navigator属性生成浏览器指纹,无头浏览器的默认配置会被瞬间识别;

专注于Python爬虫开发,分享爬虫技巧、项目实战与反爬经验,使用Scrapy、BeautifulSoup等工具,解决数据抓取难题。 2360

mybatis 超简单入门 详细图文教程

本文简单介绍了MyBatis的快速入门流程,包括环境配置、数据库准备、项目结构、核心配置文件和SQL映射文件的编写。通过创建Dept表和POJO类,利用MyBatis的配置文件和SQL映射以及代理开发和注解开发两种模式实现了数据查询功能。同时,提供了mybatis调用的优化方案,利用接口映射简化代码调用。

m0_74187645的博客 4474

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

NTscan扫描工具

ntscan是一个扫描器,可以扫描没有密码和弱密码的共享,先到配置文件中填写猜测的用户名和密码,扫描过程中右侧出现的是扫描日志。

mybatis简单入门实例

mybatis是一个数据持久层框架,他与hibernate相比,也有自己的优点,当我们进行多表关联查询的时候,很容易实现,因为他天生就是用来写sql实现功能的,而hibernate需要实现这个多表关联,也不是没有办法,就是稍微麻烦一些,hibernate是orm框架,对于简单的实体和表的映射非常的方便,但是一般的项目中,很多都是两个,甚至三个表,甚至更多表联合查询,hibernate就显得有些笨拙...

feinifi的博客 479

霍尼韦尔SoftMaster使用说明

霍尼韦尔SoftMaster使用说明

二、【MyBatis】 MyBatis入门与简单使用

Object Relation Mapping 对象关系映射。对象指的是JAVA对象,关系指的是数据库中的关系模型,对象关系映射,指的就是在JAVA对象和数据库的关系模型之间建立一种对象个关系,比如用一个Java的User类,去对应数据库中的一张表goyeer_user类,类中的属性和表中的列一一对应。User类就对应goyeer_userk类中的一行数据。我们可以使用Mybatis的注解开发一些简单映射语句,这样可以是代码显得更加简介。

记录总结工作过往 744

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

MyBatis简单例子快速入门

一、理解什么是MyBatis?   MyBatis 是支持普通 SQL 查询,存储过程和高级映射的优秀持久层框架。 MyBatis 消除了几乎所有的 JDBC 代码和参数的手工设置以及对结果集的检索。 MyBatis 可以使用简单的XML 或注解用于配置和原始映射,将接口和 Java 的 POJO( Plain Old Java Objects,普通的Java 对象)映射成数据库中的记录。 MyBATIS 目前提供了三种语言实现的版本,包括:Java、.NET以及Ruby。 它提供的持久层框架包括SQL

小强签名设计 的博客 596

Mybatis新手教程之简单入门

这篇文章主要给大家介绍了关于Mybatis新手教程之简单入门的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面来一起学习学习吧 1、Mybatis概述   MyBatis 是支持普通 SQL 查询(相比较于Hibernate的封装,Mybatis是半自动化的JDBC封装,一个特点就是Mybatis执行的SQL查询语句需要自己在配置文件中写),存储过程和高级映射的优秀持久层框架。MyBatis 消除了几乎所有的 JDBC 代码和参数的手工设...

apple_4872330的专栏 4071

MyBatis的简单入门

MyBatis的简单入门简介Eclipse 使用的使用设计模式的简介框架是什么Mybatis测试结果 简介 首先先进行一下自我介绍 爱好女,余下好多字(其他资料自己去猜) 在这个文档内有什么不懂的可以加我的QQ:1011547386 电话:13**********(保密)来随时问我,(也欢迎批评指正) 本个文档也是帮助初级学习者的入门指导(也就是大佬饶命) 我希望用一个轻松的方式来和大家一起学习s...

qq_42511420的博客 303

Mybatis简单入门

1 mybatis简单介绍 MyBatis是一个ORM的数据库持久化框架。 Mybatis是一个支撑框架,它以映射sql语句orm方式来数据库持久化操作. ORM:对象关系映射(Object Relational Mapping,简称ORM),是一种为了解决面向对象与关系数据库存在的互不匹配的现象的技术 1.1 ORM框架映射方式 Orm框架的操作数据库关系方式有很多种,常用的有两种: 1、S...

weixin_45415977的博客 257

【MyBatis】入门程序

详解编写mybatis入门程序的主要步骤,以及junit、logback和工具类 SqlSessionUtil 的封装

August_._的博客 1182

Mybatis入门

在前面我们学习MySQL数据库时,都是利用图形化客户端工具(如:idea、datagrip),来操作数据库的。在客户端工具中,编写增删改查的SQL语句,发给MySQL数据库管理系统,由数据库管理系统执行SQL语句并返回执行结果。增删改操作:返回受影响行数查询操作:返回结果集(查询的结果)我们做为后端程序开发人员,通常会使用Java程序来完成对数据库的操作。Java程序操作数据库,现在主流的方式是:Mybatis。什么是MyBatis?MyBatis是一款优秀的持久层框架,用于简化JDBC的开发。

qq_63763836的博客 1095

Mybatis入门,从一个简单的JdbcUtil开始

大学时候就学的最原始的JDBC,刚毕业那会,笔试还要求手写JDBC。什么都不说了,看代码吧。 首先,要去官网下载一个mysql的驱动包,如:mysql-connector-java-5.1.27.jar 然后,Run As Java Application package com.rice.web; import java.sql.Connection; import java.sql.Driv...

有米oooooooo 431

3.1Mybatis 入门

Mybatis笔记参考 1.环境搭建 1. 创建maven工程,导入依赖。 pom.xml <!-- mybatis--> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.5.3</vers

qq_45134373的博客 169

1、mybatis入门案例

mybatis 1、mybatis概述 mybatis是一个持久层框架,用java编写的。 它封装了jdbc操作的很多细节,使开发者只需要关注sql语句本身,而无需关注注册驱动,创建连接等繁杂过程 它使用了ORM思想实现了结果集的封装。 ORM: ​ Object Relational Mappging 对象关系映射 ​ 简单的说: ​ 就是把数据库表和实体类及实体类的属性对应起来 ​ 让我们可以操作实体类就实现操作数据库表。 ​ user User ​ id userId ​

weixin_44230693的博客 262
上一篇: VM12下配置CentOS7的静态ip配置
下一篇: Linux shell 自动安装总结
Coder-Qian
博客等级 码龄11年 63粉丝 73原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值