首页 > 其他分享 >MyBatis是什么以及为什么需要ORM框架、快速搭建

MyBatis是什么以及为什么需要ORM框架、快速搭建

时间:2024-07-02 17:52:51浏览次数:1  
标签:VARCHAR sex email ORM user jdbcType MyBatis id 搭建

MyBatis是什么

MyBatis的前身是Ibatis,本质是一款半自动化的ORM框架,除了能对POJO进行ORM映射之外,还可以编写SQL脚本语句。主要是为了解决我们平时开发中经常写的JDBC代码,将繁琐的JDBC代码封装起来,化繁为简。

MyBatis映射文件 四要素:
1.SQL语句
2.映射规则
3.POJO
4.Mapper接口

为什么需要 ORM 框架?**
传统的 JDBC 编程存在的弊端:
1.工作量大,操作数据库至少要 5 步;
2.业务代码和技术代码耦合;
3.连接资源手动关闭,带来了隐患;

MyBatis 快速入门
步骤如下:

  1. 加入 mybatis 的依赖,版本 3.5.x
	<dependency>
		<groupId>mysql</groupId>
		<artifactId>mysql-connector-java</artifactId>
		<version>5.1.18</version>
	</dependency>


	<!-- mybatis相关依赖 -->
	<dependency>
		<groupId>org.mybatis</groupId>
		<artifactId>mybatis</artifactId>
		<version>3.5.0-SNAPSHOT</version>
		<!-- <version>3.4.1</version> -->
	</dependency>

	<dependency>
		<groupId>com.github.pagehelper</groupId>
		<artifactId>pagehelper</artifactId>
		<version>5.1.4</version>
	</dependency>
	
	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-databind</artifactId>
		<version>2.9.5</version>
	</dependency>
  1. 添加 mybatis 的配置文件,包括 MyBatis 核心文件和 mapper.xml 文件
<properties resource="db.properties" />

<settings>

	<!-- 设置自动驼峰转换		 -->
	<setting name="mapUnderscoreToCamelCase" value="true" />

	<!-- 开启懒加载 -->		
	 <!-- 当启用时,有延迟加载属性的对象在被调用时将会完全加载任意属性。否则,每种属性将会按需要加载。默认:true -->
  <setting name="aggressiveLazyLoading" value="false" />

</settings>

<!-- 别名定义 -->

<typeAliases>
	<package name="com.enjoylearning.mybatis.entity" />
</typeAliases>


<!--配置environment环境 -->
<environments default="development">
	<!-- 环境配置1,每个SqlSessionFactory对应一个环境 -->
	<environment id="development">
		<transactionManager type="JDBC" />
		<dataSource type="UNPOOLED">
			<property name="driver" value="${jdbc_driver}" />
			<property name="url" value="${jdbc_url}" />
			<property name="username" value="${jdbc_username}" />
			<property name="password" value="${jdbc_password}" />
		</dataSource>
	</environment>


</environments>

<!-- 映射文件,mapper的配置文件 -->
<mappers>
	<!--直接映射到相应的mapper文件 -->
	<mapper resource="sqlmapper/TUserMapper.xml" />
</mappers>
  1. 场景介绍:基于 t_user 表单数据查询、多数据查询;

  2. 编写实体类、mapper 接口以及 mapper xml 文件;

一、Mapper.xml

<select id="selectByPrimaryKey" resultType="TUser">
	select
	id, userName, realName, sex, mobile, email, note
	from t_user
	where id = #{id,jdbcType=INTEGER}
</select>

<select id="selectAll" resultType="TUser">
	select
	id, userName, realName, sex, mobile, email, note
	from t_user
</select>

<resultMap id="UserResultMap" type="TUser" autoMapping="true">
	<id column="id" property="id" />
    <result column="userName" property="userName"/>
	<result column="realName" property="realName" />
	<result column="sex" property="sex" />
	<result column="mobile" property="mobile" />
	<result column="email" property="email" />
	<result column="note" property="note" />
	<association property="position" javaType="TPosition" columnPrefix="post_">
		<id column="id" property="id"/>
		<result column="name" property="postName"/>
		<result column="note" property="note"/>
	</association>
</resultMap>

<select id="selectTestResultMap" resultMap="UserResultMap" >
	select
	    a.id, 
	    userName,
		realName,
		sex,
		mobile,
		email,
		a.note,
		b.id  post_id,
		b.post_name,
		b.note post_note
	from t_user a,
		t_position b
	where a.position_id = b.id

</select>
<resultMap id="BaseResultMap" type="TUser">

	<!-- <constructor> <idArg column="id" javaType="int"/> <arg column="userName" 
		javaType="String"/> </constructor> -->
	<id column="id" property="id" />
	<result column="userName" property="userName" />
	<result column="realName" property="realName" />
	<result column="sex" property="sex" />
	<result column="mobile" property="mobile" />
	<result column="email" property="email" />
	<result column="note" property="note" />
</resultMap>

<sql id="Base_Column_List">
	id, userName, realName, sex, mobile, email, note,
	position_id
</sql>

<resultMap id="userAndPosition1" extends="BaseResultMap" type="TUser">
	<association property="position" javaType="TPosition" columnPrefix="post_">
		<id column="id" property="id"/>
		<result column="name" property="postName"/>
		<result column="note" property="note"/>
	</association>
</resultMap>

<resultMap id="userAndPosition2" extends="BaseResultMap" type="TUser">
	<association property="position" fetchType="lazy"  column="position_id" select="com.enjoylearning.mybatis.mapper.TPositionMapper.selectByPrimaryKey" />
</resultMap>

<select id="selectUserPosition1" resultMap="userAndPosition1" >
	select
	    a.id, 
	    userName,
		realName,
		sex,
		mobile,
		email,
		a.note,
		b.id post_id,
		b.post_name,
		b.note post_note
	from t_user a,
		t_position b
	where a.position_id = b.id

</select>

<select id="selectUserPosition2" resultMap="userAndPosition2" >
	select
	a.id,
	a.userName,
	a.realName,
	a.sex,
	a.mobile,
	a.position_id
	from t_user a
</select>


<resultMap id="userAndJobs1" extends="BaseResultMap" type="TUser">
	<collection property="jobs"
		ofType="com.enjoylearning.mybatis.entity.TJobHistory" >
		<result column="comp_name" property="compName" jdbcType="VARCHAR" />
		<result column="years" property="years" jdbcType="INTEGER" />
		<result column="title" property="title" jdbcType="VARCHAR" />
	</collection>
</resultMap>

<resultMap id="userAndJobs2" extends="BaseResultMap" type="TUser">
	<collection property="jobs" fetchType="lazy" column="id"
		select="com.enjoylearning.mybatis.mapper.TJobHistoryMapper.selectByUserId" />
</resultMap>

<select id="selectUserJobs1" resultMap="userAndJobs1">
	select
	a.id,
	a.userName,
	a.realName,
	a.sex,
	a.mobile,
	b.comp_name,
	b.years,
	b.title
	from t_user a,
	t_job_history b
	where a.id = b.user_id

</select>

<select id="selectUserJobs2" resultMap="userAndJobs2">
	select
	a.id,
	a.userName,
	a.realName,
	a.sex,
	a.mobile
	from t_user a
</select>


<resultMap id="userAndHealthReportMale" extends="userAndHealthReport" type="TUser">
	<collection property="healthReports" column="id"
		select= "com.enjoylearning.mybatis.mapper.THealthReportMaleMapper.selectByUserId"></collection>
</resultMap>

<resultMap id="userAndHealthReportFemale" extends="userAndHealthReport" type="TUser">
	<collection property="healthReports" column="id"
		select= "com.enjoylearning.mybatis.mapper.THealthReportFemaleMapper.selectByUserId"></collection>
</resultMap>

<resultMap id="userAndHealthReport" extends="BaseResultMap" type="TUser">
			 
	<discriminator column="sex"  javaType="int">
		<case value="1" resultMap="userAndHealthReportMale"/>
		<case value="2" resultMap="userAndHealthReportFemale"/>
	</discriminator>
</resultMap>


<select id="selectUserHealthReport" resultMap="userAndHealthReport">
	select
	<include refid="Base_Column_List" />
	from t_user a
</select>

<resultMap type="TUser" id="userRoleInfo" extends="BaseResultMap">
	<collection property="roles" ofType="TRole" columnPrefix="role_">
		<result column="id" property="id" />
		<result column="Name" property="roleName" />
		<result column="note" property="note" />
	</collection>
</resultMap>


<select id="selectUserRole" resultMap="userRoleInfo">
	select a.id, 
	      a.userName,
	      a.realName,
	      a.sex,
	      a.mobile,
	      a.note,
	      b.role_id,
	      c.role_name,
	      c.note role_note
	from t_user a,
	     t_user_role b,
	     t_role c
	where a.id = b.user_id AND 
	      b.role_id = c.id
 </select>	
 
 
 <select id="selectUserByRoleId" resultMap="userRoleInfo">
    select
	<include refid="Base_Column_List" />
	from t_user a,
	     t_user_role b
	where a.id = b.user_id and
	      b.role_id = #{id}
 </select>	


<select id="selectByEmailAndSex1" resultMap="BaseResultMap"		parameterType="map">
	select
	<include refid="Base_Column_List" />
	from t_user a
	 where a.email like CONCAT('%', #{email}, '%') and
	 a.sex =#{sex} 
</select>

<select id="selectByEmailAndSex2" resultMap="BaseResultMap">
	select
	<include refid="Base_Column_List" />
	from t_user a
	where a.email like CONCAT('%', #{email}, '%') and
	a.sex =	#{sex}
</select>


<select id="selectByEmailAndSex3" resultMap="BaseResultMap"
	parameterType="com.enjoylearning.mybatis.entity.EmailSexBean">
	select
	<include refid="Base_Column_List" />
	from t_user a
	where a.email like CONCAT('%', #{email}, '%') and
	a.sex =	#{sex}
</select>


<select id="selectBySymbol" resultMap="BaseResultMap">
	select
	${inCol}
	from ${tableName} a
	where a.userName = #{userName}
	order by ${orderStr}
</select>



<select id="selectIfOper" resultMap="BaseResultMap">
	select
	<include refid="Base_Column_List" />
	from t_user a
	where   1=1  
	<if test="email != null and email != ''">
		and a.email like CONCAT('%', #{email}, '%') 
	</if>
	<if test="sex != null ">
		and a.sex = #{sex}
	</if>
</select>

<select id="selectIfandWhereOper" resultMap="BaseResultMap">
	select
	<include refid="Base_Column_List" />
	from t_user a
	<where>
		<if test="email != null and email != ''">
			and a.email like CONCAT('%', #{email}, '%')
		</if>
		<if test="sex != null ">
			and a.sex = #{sex}
		</if>
	</where>
</select>

<select id="selectChooseOper" resultMap="BaseResultMap">
	select
	<include refid="Base_Column_List" />
	from t_user a
	<where>
		<choose>
			<when test="email != null and email != ''">
				and a.email like CONCAT('%', #{email}, '%')
			</when>
			<when test="sex != null">
				and a.sex = #{sex}
			</when>
			<otherwise>
				and 1=1
			</otherwise>
		
		
		</choose>
	</where>
</select>

<update id="updateIfOper" parameterType="TUser">
	update t_user
	set
	<if test="userName != null">
		userName = #{userName,jdbcType=VARCHAR},
	</if>
	<if test="realName != null">
		realName = #{realName,jdbcType=VARCHAR},
	</if>
	<if test="sex != null">
		sex = #{sex,jdbcType=TINYINT},
	</if>
	<if test="mobile != null">
		mobile = #{mobile,jdbcType=VARCHAR},
	</if>
	<if test="email != null">
		email = #{email,jdbcType=VARCHAR},
	</if>
	<if test="note != null">
		note = #{note,jdbcType=VARCHAR}
	</if>
	where id = #{id,jdbcType=INTEGER}
</update>

<update id="updateIfAndSetOper" parameterType="TUser">

    update t_user
	<set>
		<if test="userName != null">
			userName = #{userName,jdbcType=VARCHAR},
		</if>
		<if test="realName != null">
			realName = #{realName,jdbcType=VARCHAR},
		</if>
		<if test="sex != null">
			sex = #{sex,jdbcType=TINYINT},
		</if>
		<if test="mobile != null">
			mobile = #{mobile,jdbcType=VARCHAR},
		</if>
		<if test="email != null">
			email = #{email,jdbcType=VARCHAR},
		</if>
		<if test="note != null">
			note = #{note,jdbcType=VARCHAR},
		</if>
	</set>
	where id = #{id,jdbcType=INTEGER} 
</update>


<insert id="insertIfOper" parameterType="TUser">
	insert into t_user (
	<if test="id != null">
		id,
	</if>
	<if test="userName != null">
		userName,
	</if>
	<if test="realName != null">
		realName,
	</if>
	<if test="sex != null">
		sex,
	</if>
	<if test="mobile != null">
		mobile,
	</if>
	<if test="email != null">
		email,
	</if>
	<if test="note != null">
		note
	</if>
	)
	values(
	<if test="id != null">
		#{id,jdbcType=INTEGER},
	</if>
	<if test="userName != null">
		#{userName,jdbcType=VARCHAR},
	</if>
	<if test="realName != null">
		#{realName,jdbcType=VARCHAR},
	</if>
	<if test="sex != null">
		#{sex,jdbcType=TINYINT},
	</if>
	<if test="mobile != null">
		#{mobile,jdbcType=VARCHAR},
	</if>
	<if test="email != null">
		#{email,jdbcType=VARCHAR},
	</if>
	<if test="note != null">
		#{note,jdbcType=VARCHAR}
	</if>
	)
</insert>


<select id="selectForeach4In" resultMap="BaseResultMap">
	select
	<include refid="Base_Column_List" />
	from t_user a
	where a.userName in
	<foreach collection="array" open="(" close=")" item="userName" separator=",">
		#{userName}
	</foreach> 
</select>

<insert id="insertForeach4Batch" useGeneratedKeys="true"		keyProperty="id">
	insert into t_user (userName, realName,
	sex, mobile,email,note,
	position_id)
	values
	<foreach collection="list" separator="," item="user">
		(
		#{user.userName,jdbcType=VARCHAR},
		#{user.realName,jdbcType=VARCHAR},
		#{user.sex,jdbcType=TINYINT},
		#{user.mobile,jdbcType=VARCHAR},
		#{user.email,jdbcType=VARCHAR},
		#{user.note,jdbcType=VARCHAR},
		#{user.position.id,jdbcType=INTEGER}
		)
	</foreach>

</insert>


<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
	delete from t_user
	where id = #{id,jdbcType=INTEGER}
</delete>

<insert id="insert1" parameterType="TUser" useGeneratedKeys="true"	keyProperty="id">
	insert into t_user (id, userName, realName,
	sex, mobile,
	email,
	note, position_id)
	values (#{id,jdbcType=INTEGER},
	#{userName,jdbcType=VARCHAR},
	#{realName,jdbcType=VARCHAR},
	#{sex,jdbcType=TINYINT}, #{mobile,jdbcType=VARCHAR},
	#{email,jdbcType=VARCHAR},
	#{note,jdbcType=VARCHAR},
	#{position.id,jdbcType=INTEGER})
</insert>

<insert id="insert2" parameterType="TUser">

	<selectKey keyProperty="id" order="AFTER" resultType="int">
		select
		LAST_INSERT_ID()
	</selectKey>
	insert into t_user (id, userName, realName,
	sex, mobile,
	email,
	note,
	position_id)
	values (#{id,jdbcType=INTEGER},
	#{userName,jdbcType=VARCHAR},
	#{realName,jdbcType=VARCHAR},
	#{sex,jdbcType=TINYINT}, #{mobile,jdbcType=VARCHAR},
	#{email,jdbcType=VARCHAR},
	#{note,jdbcType=VARCHAR},
	#{position.id,jdbcType=INTEGER})
</insert>

<insert id="insertSelective" parameterType="TUser" useGeneratedKeys="true"		keyProperty="id">
	insert into t_user
	<trim prefix="(" suffix=")" suffixOverrides="," >
		<if test="id != null">
			id,
		</if>
		<if test="userName != null">
			userName,
		</if>
		<if test="realName != null">
			realName,
		</if>
		<if test="sex != null">
			sex,
		</if>
		<if test="mobile != null">
			mobile,
		</if>
		<if test="email != null">
			email,
		</if>
		<if test="note != null">
			note,
		</if>
	</trim>
	<trim prefix="values (" suffix=")" suffixOverrides=",">
		<if test="id != null">
			#{id,jdbcType=INTEGER},
		</if>
		<if test="userName != null">
			#{userName,jdbcType=VARCHAR},
		</if>
		<if test="realName != null">
			#{realName,jdbcType=VARCHAR},
		</if>
		<if test="sex != null">
			#{sex,jdbcType=TINYINT},
		</if>
		<if test="mobile != null">
			#{mobile,jdbcType=VARCHAR},
		</if>
		<if test="email != null">
			#{email,jdbcType=VARCHAR},
		</if>
		<if test="note != null">
			#{note,jdbcType=VARCHAR},
		</if>
	</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="TUser">
	update t_user
	<set>
		<if test="userName != null">
			userName = #{userName,jdbcType=VARCHAR},
		</if>
		<if test="realName != null">
			realName = #{realName,jdbcType=VARCHAR},
		</if>
		<if test="sex != null">
			sex = #{sex,jdbcType=TINYINT},
		</if>
		<if test="mobile != null">
			mobile = #{mobile,jdbcType=VARCHAR},
		</if>
		<if test="email != null">
			email = #{email,jdbcType=VARCHAR},
		</if>
		<if test="note != null">
			note = #{note,jdbcType=VARCHAR},
		</if>
		<if test="position != null">
			position_id = #{position.id,jdbcType=INTEGER},
		</if>
	</set>
	where id = #{id,jdbcType=INTEGER}
</update>
<update id="updateByPrimaryKey" parameterType="TUser">
	update t_user
	set
	userName = #{userName,jdbcType=VARCHAR},
	realName =
	#{realName,jdbcType=VARCHAR},
	sex = #{sex,jdbcType=TINYINT},
	mobile =
	#{mobile,jdbcType=VARCHAR},
	email = #{email,jdbcType=VARCHAR},
	note =
	#{note,jdbcType=VARCHAR},
	position_id = #{position.id,jdbcType=INTEGER}
	where id = #{id,jdbcType=INTEGER}
</update>

二、实体类
package com.enjoylearning.mybatis.entity;

import java.io.Serializable;
import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.mysql.jdbc.Blob;

public class TUser implements Serializable{

private Integer id;

private String userName;

private String realName;

private Byte sex;

private String mobile;

private String email;

private String note;

private TPosition position;

private List<TJobHistory> jobs ;

private List<HealthReport> healthReports;


private List<TRole> roles;

@Override
public String toString() {
	String positionId=  (position == null ? "" : String.valueOf(position.getId()));
	return "TUser [id=" + id + ", userName=" + userName + ", realName="
			+ realName + ", sex=" + sex + ", mobile=" + mobile + ", email="
			+ email + ", note=" + note + ", positionId=" + positionId + "]";
}

public Integer getId() {
	return id;
}

public void setId(Integer id) {
	this.id = id;
}

public String getUserName() {
	return userName;
}

public void setUserName(String userName) {
	this.userName = userName;
}

public String getRealName() {
	return realName;
}

public void setRealName(String realName) {
	this.realName = realName;
}

public Byte getSex() {
	return sex;
}

public void setSex(Byte sex) {
	this.sex = sex;
}

public String getMobile() {
	return mobile;
}

public void setMobile(String mobile) {
	this.mobile = mobile;
}

public String getEmail() {
	return email;
}

public void setEmail(String email) {
	this.email = email;
}

public String getNote() {
	return note;
}

public void setNote(String note) {
	this.note = note;
}

public TPosition getPosition() {
	return position;
}

public void setPosition(TPosition position) {
	this.position = position;
}

public List<TJobHistory> getJobs() {
	return jobs;
}

public void setJobs(List<TJobHistory> jobs) {
	this.jobs = jobs;
}

public List<HealthReport> getHealthReports() {
	return healthReports;
}

public void setHealthReports(List<HealthReport> healthReports) {
	this.healthReports = healthReports;
}

public List<TRole> getRoles() {
	return roles;
}

public void setRoles(List<TRole> roles) {
	this.roles = roles;
}

public static void main(String[] args) {
	System.out.println(1<<2);
} 

}

三、Mapper接口
package com.enjoylearning.mybatis.mapper;

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

import org.apache.ibatis.annotations.Param;

import com.enjoylearning.mybatis.entity.EmailSexBean;
import com.enjoylearning.mybatis.entity.TJobHistory;
import com.enjoylearning.mybatis.entity.TUser;

public interface TUserMapper {

TUser selectByPrimaryKey(Integer id);


List<TUser> selectAll();

List<TUser> selectTestResultMap();

List<TUser> selectAllTest();


int deleteByPrimaryKey(Integer id);

int insert1(TUser record);

int insert2(TUser record);

int insertSelective(TUser record);


int updateByPrimaryKeySelective(TUser record);

int updateByPrimaryKey(TUser record);


List<TUser> selectUserPosition1();

List<TUser> selectUserPosition2();

List<TUser> selectUserJobs1();

List<TUser> selectUserJobs2();

List<TUser> selectUserHealthReport();

List<TUser> selectUserRole();

List<TUser> selectByEmailAndSex1(Map<String, Object> param);

List<TUser> selectByEmailAndSex2(@Param("email")String email,@Param("sex")Byte sex);

List<TUser> selectByEmailAndSex3(EmailSexBean esb);


List<TUser> selectBySymbol(@Param("tableName")String tableName,
		                   @Param("inCol")String inCol,
		                   @Param("orderStr")String orderStr,
		                   @Param("userName")String userName);

List<TUser> selectIfOper(@Param("email")String email,@Param("sex")Byte sex);


List<TUser> selectIfandWhereOper(@Param("email")String email,@Param("sex")Byte sex);

List<TUser> selectChooseOper(@Param("email")String email,@Param("sex")Byte sex);

int updateIfOper(TUser record);

int updateIfAndSetOper(TUser record);

int insertIfOper(TUser record);

List<TUser> selectForeach4In(String[] names);

int insertForeach4Batch(List<TUser> users);

}

  1. 编写实例代码:com.enjoylearning.mybatis.MybatisDemo. quickStart

public class MybatisDemo {

private SqlSessionFactory sqlSessionFactory;

@Before
public void init() throws IOException {
	//--------------------第一阶段---------------------------
    // 1.读取mybatis配置文件创SqlSessionFactory
	String resource = "mybatis-config.xml";
	InputStream inputStream = Resources.getResourceAsStream(resource);
	// 1.读取mybatis配置文件创SqlSessionFactory
	sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
	inputStream.close();
}

@Test
// 快速入门
public void quickStart() throws IOException {
	//--------------------第二阶段---------------------------
	// 2.获取sqlSession	
	SqlSession sqlSession = sqlSessionFactory.openSession();
	// 3.获取对应mapper
	TUserMapper mapper = sqlSession.getMapper(TUserMapper.class);
	
	//--------------------第三阶段---------------------------
	// 4.执行查询语句并返回单条数据
	TUser user = mapper.selectByPrimaryKey(1);
	System.out.println(user);
	
	System.out.println("----------------------------------");
	
	// 5.执行查询语句并返回多条数据
	List<TUser> users = mapper.selectAll();
	for (TUser tUser : users) {
		System.out.println(tUser);
	}
}

标签:VARCHAR,sex,email,ORM,user,jdbcType,MyBatis,id,搭建
From: https://www.cnblogs.com/velloLei/p/18280307

相关文章

  • String.format 日期占位 去除左侧的填充0
    原文链接: https://baijiahao.baidu.com/s?id=1764834107971798887&wfr=spider&for=pc假设我们要输出当前的日期时间,我们可以使用如下代码:Datedate=newDate();System.out.println("输出结果:"+String.format("%tF%tT",date,date));输出结果为:输出结果:2023-......
  • 《DNK210使用指南 -CanMV版 V1.0》第七章 基于CanMV的MicroPython语法开发环境搭建
    第七章基于CanMV的MicroPython语法开发环境搭建1)实验平台:正点原子DNK210开发板2)章节摘自【正点原子】DNK210使用指南-CanMV版V1.03)购买链接:https://detail.tmall.com/item.htm?&id=7828013987504)全套实验源码+手册+视频下载地址:http://www.openedv.com/docs/boards/k210/......
  • 《刚刚问世》系列初窥篇-Java+Playwright自动化测试-1-环境准备与搭建
    1.简介Python+Playwright系列的文章还没有结束,就有好的小伙伴或者童鞋们私信公众号留言,问宏哥什么时候出Java语言的Playwright的自动化测试文章。本来想趁热打铁将Python+Playwright完结后,就开始Java语言的Playwright的自动化测试文章,但是好多人私信留言,索性就两个系列的文章......
  • 短视频矩阵/系统搭建/源码(HYT0606006)
    短视频矩阵的搭建通常涉及到内容管理系统(CMS)的集成、视频上传和管理功能、推荐算法、用户互动以及数据分析等多个组件。以下是构建短视频矩阵系统的一般步骤:需求分析:明确平台的目标用户、内容类型、功能需求,如社交分享、评论、点赞等。技术选型:选择后端框架(如Node.js、Pyth......
  • windows10用conda搭建tensorflow的gpu环境
    在tensorflow官方网址上也列举了很多方法,但都很麻烦,包括docker也没有办法在win10下应用gpu来计算。记录我的检查过程。在官网搜集有用的资料。“在Windows环境中从源代码构建”中提到了经过测试后,可用的配套版本,找到一个最新的是:|版本|Python版......
  • 对Transformer的一些理解
    在学习Transformer这个模型前对seq2seq架构有个了解时很有必要的先上图输入和输出首先理解模型时第一眼应该理解输入和输出最开始我就非常纠结有一个Inputs,一个Outputs(shiftright)和一个OutputProbabilities,首先需要借助这三个输入/输出来初步了解该模型的运行方式。这......
  • 从零到一 Instagram自动运营脚本源码搭建/配置详解
    对于希望在Instagram上实现高效自动运营的用户而言,搭建一套个性化脚本至关重要。本文将从源码层面出发,详解如何从零到一构建并配置Instagram自动运营脚本。一、项目规划明确自动化目标:如提升曝光、增加粉丝、维护用户关系等。设计脚本框架:包括登录模块、任务调度模块、执行模......
  • 飞书集成机器人搭建实战/多平台整合机器人源码部署流程
    一、引言在当今数字化办公时代,多平台整合成为提高工作效率的关键。飞书集成机器人能够打通不同平台之间的壁垒,实现信息的快速流通和协同办公。本文将带您实战搭建飞书集成机器人,并详细介绍多平台整合机器人的源码部署流程。二、集成需求分析在开始搭建之前,我们需要明确集成......
  • .Net Core Web Api 框架搭建详细步骤
    1、建立.NetCoreWebApi项目2、新建类库,分类结构层 3、使用EFCORE链接数据库,关联实体创建表,添加以下Nuget包创建DbContext 实例  4、appsettings.json配置数据库链接字符串,我当前是链接的mysql数据库5、Program依赖关系注入DbContextbuilder.Services.Ad......
  • .Net Core Web Api 框架搭建简单步骤
    1、建立.NetCoreWebApi项目2、新建相关类库项目3、在EFCORE项目中,创建DbContext 上下文实例,并将所有的实体类写入DbSet,在Program.cs中注入创建的DbContext 实力及配置数据库链接信息4、封装DbContext 仓储类Repository5、新建服务类及服务接口,继承仓储类进行数据增......