Mybatis:MyBatis的逆向工程(10)

news2024/11/30 4:58:59

Mybaits笔记框架:https://blog.csdn.net/qq_43751200/article/details/128154837
Mybatis中文官方文档: https://mybatis.org/mybatis-3/zh/index.html

Mybati的逆向工程

  • 1. 正向工程 VS 逆向工程
  • 2. 创建逆向工程的步骤(MyBatis3Simple清新简洁版)
    • 2.1 添加依赖和插件
    • 2.2 创建MyBatis的核心配置文件
    • 2.3 创建逆向工程的配置文件
    • 2.4 项目总体结构
    • 2.5 执行MBG插件的generate目标
    • 2.6 项目最终结构
    • 2.7 生成的实体类、接口、配置文件查看
  • 3. 创建逆向工程的步骤(MyBatis3奢华尊享版)

1. 正向工程 VS 逆向工程

  • 正向工程:先创建Java实体类,由框架负责根据实体类生成数据库表。Hibernate是支持正向工程的

  • 逆向工程:先创建数据库表,由框架负责根据数据库表,反向生成如下资源:

    • Java实体类
    • Mapper接口
    • Mapper映射文件

2. 创建逆向工程的步骤(MyBatis3Simple清新简洁版)

2.1 添加依赖和插件

<?xml version="1.0" encoding="UTF-8"?>
<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>org.example</groupId>
    <artifactId>mybatis_05_MBG</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.20</version>
        </dependency>
        <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.5.6</version>
        </dependency>
    </dependencies>

    <!-- 控制Maven在构建过程中相关配置 -->
    <build>
        <!-- 构建过程中用到的插件 -->
        <plugins>
            <!-- 具体插件,逆向工程的操作是以构建过程中插件形式出现的 -->
            <plugin>
                <groupId>org.mybatis.generator</groupId>
                <artifactId>mybatis-generator-maven-plugin</artifactId>
                <version>1.3.0</version>
                <!-- 插件的依赖 -->
                <dependencies>
                    <!-- 逆向工程的核心依赖 -->
                    <dependency>
                        <groupId>org.mybatis.generator</groupId>
                        <artifactId>mybatis-generator-core</artifactId>
                        <version>1.3.2</version>
                    </dependency>
                    <!-- 数据库连接池 -->
                    <dependency>
                        <groupId>com.mchange</groupId>
                        <artifactId>c3p0</artifactId>
                        <version>0.9.2</version>
                    </dependency>
                    <!-- MySQL驱动 -->
                    <dependency>
                        <groupId>mysql</groupId>
                        <artifactId>mysql-connector-java</artifactId>
                        <version>8.0.27</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

</project>

2.2 创建MyBatis的核心配置文件

<?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 resource="jdbc.properties"/>

    <!--设置Mybatis的全局配置-->
    <settings>
        <!--将下划线_自动映射为驼峰,emp_name : empName -->
        <setting name="mapUnderscoreToCamelCase" value="true"/>
        <!--开启延迟加载-->
        <setting name="lazyLoadingEnabled" value="true"/>
    </settings>

    <!-- 给实体类起别名 -->
    <typeAliases>
        <!--
        typeAlias:设置某个具体的类型的别名
        属性:
        type:需要设置别名的类型的全类名
        alias:设置此类型的别名,且别名不区分大小写。若不设置此属性,该类型拥有默认的别名,即类名
        -->
        <!--<typeAlias type="com.atguigu.mybatis.bean.User"></typeAlias>-->
        <!--<typeAlias type="com.atguigu.mybatis.bean.User" alias="user">
        </typeAlias>-->
        <!--以包为单位,设置改包下所有的类型都拥有默认的别名,即类名且不区分大小写-->
        <package name="com.atguigu.pojo"/>
    </typeAliases>

    <environments default="development">
        <environment id="development">
            <transactionManager type="JDBC"/>
            <dataSource type="POOLED">
                <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>

    <!-- 映射文件XXXMapper.xml所在的包 -->
    <mappers>
        <!--
        以包为单位,将包下所有的映射文件引入核心配置文件
        注意:
			1. 此方式必须保证mapper接口和mapper映射文件必须在相同的包下
			2. mapper接口要和mapper映射文件的名字一致
        -->
        <package name="com.atguigu.mapper"/>
    </mappers>
</configuration>

2.3 创建逆向工程的配置文件

逆向工程的配置文件名必须是generatorConfig.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
    <!--
        targetRuntime: 执行生成的逆向工程的版本
        MyBatis3Simple: 生成基本的CRUD(清新简洁版)
        MyBatis3: 生成带条件的CRUD(奢华尊享版)
    -->
    <context id="DB2Tables" targetRuntime="MyBatis3Simple">
        <!-- 数据库的连接信息 -->
        <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/mybatis?useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=GMT%2B8"
                        userId="root"
                        password="1234">
        </jdbcConnection>
        <!-- javaBean的生成策略-->
        <javaModelGenerator targetPackage="com.atguigu.pojo" targetProject=".\src\main\java">
            <property name="enableSubPackages" value="true"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>
        <!-- SQL映射文件的生成策略 -->
        <sqlMapGenerator targetPackage="com.atguigu.mapper"
                         targetProject=".\src\main\resources">
            <property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>
        <!-- Mapper接口的生成策略 -->
        <javaClientGenerator type="XMLMAPPER"
                             targetPackage="com.atguigu.mapper" targetProject=".\src\main\java">
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>
        <!-- 逆向分析的表 -->
        <!-- tableName设置为*号,可以对应所有表,此时不写domainObjectName -->
        <!-- domainObjectName属性指定生成出来的实体类的类名 -->
        <table tableName="t_emp" domainObjectName="Emp"/>
        <table tableName="t_dept" domainObjectName="Dept"/>
    </context>
</generatorConfiguration>

2.4 项目总体结构

在这里插入图片描述

2.5 执行MBG插件的generate目标

在这里插入图片描述

在这里插入图片描述

2.6 项目最终结构

在这里插入图片描述

2.7 生成的实体类、接口、配置文件查看

Dept

package com.atguigu.pojo;

public class Dept {
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_dept.did
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    private Integer did;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_dept.dept_name
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    private String deptName;

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_dept.did
     *
     * @return the value of t_dept.did
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public Integer getDid() {
        return did;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_dept.did
     *
     * @param did the value for t_dept.did
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public void setDid(Integer did) {
        this.did = did;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_dept.dept_name
     *
     * @return the value of t_dept.dept_name
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public String getDeptName() {
        return deptName;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_dept.dept_name
     *
     * @param deptName the value for t_dept.dept_name
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public void setDeptName(String deptName) {
        this.deptName = deptName == null ? null : deptName.trim();
    }
}

Emp

package com.atguigu.pojo;

public class Emp {
    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_emp.eid
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    private Integer eid;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_emp.emp_name
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    private String empName;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_emp.age
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    private Integer age;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_emp.sex
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    private String sex;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_emp.email
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    private String email;

    /**
     * This field was generated by MyBatis Generator.
     * This field corresponds to the database column t_emp.did
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    private Integer did;

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_emp.eid
     *
     * @return the value of t_emp.eid
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public Integer getEid() {
        return eid;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_emp.eid
     *
     * @param eid the value for t_emp.eid
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public void setEid(Integer eid) {
        this.eid = eid;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_emp.emp_name
     *
     * @return the value of t_emp.emp_name
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public String getEmpName() {
        return empName;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_emp.emp_name
     *
     * @param empName the value for t_emp.emp_name
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public void setEmpName(String empName) {
        this.empName = empName == null ? null : empName.trim();
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_emp.age
     *
     * @return the value of t_emp.age
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public Integer getAge() {
        return age;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_emp.age
     *
     * @param age the value for t_emp.age
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public void setAge(Integer age) {
        this.age = age;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_emp.sex
     *
     * @return the value of t_emp.sex
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public String getSex() {
        return sex;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_emp.sex
     *
     * @param sex the value for t_emp.sex
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public void setSex(String sex) {
        this.sex = sex == null ? null : sex.trim();
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_emp.email
     *
     * @return the value of t_emp.email
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public String getEmail() {
        return email;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_emp.email
     *
     * @param email the value for t_emp.email
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public void setEmail(String email) {
        this.email = email == null ? null : email.trim();
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method returns the value of the database column t_emp.did
     *
     * @return the value of t_emp.did
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public Integer getDid() {
        return did;
    }

    /**
     * This method was generated by MyBatis Generator.
     * This method sets the value of the database column t_emp.did
     *
     * @param did the value for t_emp.did
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    public void setDid(Integer did) {
        this.did = did;
    }
}

DeptMapper: 自动生成有增删改查方法

package com.atguigu.mapper;

import com.atguigu.pojo.Dept;
import java.util.List;

public interface DeptMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_dept
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    int insert(Dept record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_dept
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    List<Dept> selectAll();
}

EmpMapper: 自动生成有增删改查方法

package com.atguigu.mapper;

import com.atguigu.pojo.Emp;
import java.util.List;

public interface EmpMapper {
    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_emp
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    int deleteByPrimaryKey(Integer eid);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_emp
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    int insert(Emp record);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_emp
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    Emp selectByPrimaryKey(Integer eid);

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_emp
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    List<Emp> selectAll();

    /**
     * This method was generated by MyBatis Generator.
     * This method corresponds to the database table t_emp
     *
     * @mbggenerated Tue Dec 13 10:17:42 CST 2022
     */
    int updateByPrimaryKey(Emp record);
}

DeptMapper.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.atguigu.mapper.DeptMapper" >
  <resultMap id="BaseResultMap" type="com.atguigu.pojo.Dept" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Dec 13 10:17:42 CST 2022.
    -->
    <result column="did" property="did" jdbcType="INTEGER" />
    <result column="dept_name" property="deptName" jdbcType="VARCHAR" />
  </resultMap>
  <insert id="insert" parameterType="com.atguigu.pojo.Dept" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Dec 13 10:17:42 CST 2022.
    -->
    insert into t_dept (did, dept_name)
    values (#{did,jdbcType=INTEGER}, #{deptName,jdbcType=VARCHAR})
  </insert>
  <select id="selectAll" resultMap="BaseResultMap" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Dec 13 10:17:42 CST 2022.
    -->
    select did, dept_name
    from t_dept
  </select>
</mapper>

EmpMapper.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.atguigu.mapper.EmpMapper" >
  <resultMap id="BaseResultMap" type="com.atguigu.pojo.Emp" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Dec 13 10:17:42 CST 2022.
    -->
    <id column="eid" property="eid" jdbcType="INTEGER" />
    <result column="emp_name" property="empName" jdbcType="VARCHAR" />
    <result column="age" property="age" jdbcType="INTEGER" />
    <result column="sex" property="sex" jdbcType="CHAR" />
    <result column="email" property="email" jdbcType="VARCHAR" />
    <result column="did" property="did" jdbcType="INTEGER" />
  </resultMap>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Dec 13 10:17:42 CST 2022.
    -->
    delete from t_emp
    where eid = #{eid,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.atguigu.pojo.Emp" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Dec 13 10:17:42 CST 2022.
    -->
    insert into t_emp (eid, emp_name, age, 
      sex, email, did)
    values (#{eid,jdbcType=INTEGER}, #{empName,jdbcType=VARCHAR}, #{age,jdbcType=INTEGER}, 
      #{sex,jdbcType=CHAR}, #{email,jdbcType=VARCHAR}, #{did,jdbcType=INTEGER})
  </insert>
  <update id="updateByPrimaryKey" parameterType="com.atguigu.pojo.Emp" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Dec 13 10:17:42 CST 2022.
    -->
    update t_emp
    set emp_name = #{empName,jdbcType=VARCHAR},
      age = #{age,jdbcType=INTEGER},
      sex = #{sex,jdbcType=CHAR},
      email = #{email,jdbcType=VARCHAR},
      did = #{did,jdbcType=INTEGER}
    where eid = #{eid,jdbcType=INTEGER}
  </update>
  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Dec 13 10:17:42 CST 2022.
    -->
    select eid, emp_name, age, sex, email, did
    from t_emp
    where eid = #{eid,jdbcType=INTEGER}
  </select>
  <select id="selectAll" resultMap="BaseResultMap" >
    <!--
      WARNING - @mbggenerated
      This element is automatically generated by MyBatis Generator, do not modify.
      This element was generated on Tue Dec 13 10:17:42 CST 2022.
    -->
    select eid, emp_name, age, sex, email, did
    from t_emp
  </select>
</mapper>

3. 创建逆向工程的步骤(MyBatis3奢华尊享版)

只需要修改generatorConfig.xml配置文件,将targetRuntime="MyBatis3Simple"修改为targetRuntime="MyBatis3"即可

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE generatorConfiguration
        PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN"
        "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd">
<generatorConfiguration>
    <!--
        targetRuntime: 执行生成的逆向工程的版本
        MyBatis3Simple: 生成基本的CRUD(清新简洁版)
        MyBatis3: 生成带条件的CRUD(奢华尊享版)
    -->
    <context id="DB2Tables" targetRuntime="MyBatis3">
        <!-- 数据库的连接信息 -->
        <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/mybatis?useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8&amp;serverTimezone=GMT%2B8"
                        userId="root"
                        password="1234">
        </jdbcConnection>
        <!-- javaBean的生成策略-->
        <javaModelGenerator targetPackage="com.atguigu.pojo" targetProject=".\src\main\java">
            <property name="enableSubPackages" value="true"/>
            <property name="trimStrings" value="true"/>
        </javaModelGenerator>
        <!-- SQL映射文件的生成策略 -->
        <sqlMapGenerator targetPackage="com.atguigu.mapper"
                         targetProject=".\src\main\resources">
            <property name="enableSubPackages" value="true"/>
        </sqlMapGenerator>
        <!-- Mapper接口的生成策略 -->
        <javaClientGenerator type="XMLMAPPER"
                             targetPackage="com.atguigu.mapper" targetProject=".\src\main\java">
            <property name="enableSubPackages" value="true"/>
        </javaClientGenerator>
        <!-- 逆向分析的表 -->
        <!-- tableName设置为*号,可以对应所有表,此时不写domainObjectName -->
        <!-- domainObjectName属性指定生成出来的实体类的类名 -->
        <table tableName="t_emp" domainObjectName="Emp"/>
        <table tableName="t_dept" domainObjectName="Dept"/>
    </context>
</generatorConfiguration>

生成的项目框架

在这里插入图片描述

测试方法

 @Test
    public void testMethod(){
        try {
            InputStream is = Resources.getResourceAsStream("mybatis-config.xml");
            SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(is);
            SqlSession sqlSession = sqlSessionFactory.openSession(true);
            EmpMapper empMapper = sqlSession.getMapper(EmpMapper.class);
            // 根据条件查询
            EmpExample empExample = new EmpExample();
            // 标准一:name为lsm且年龄等于231
            empExample.createCriteria().andEmpNameEqualTo("lsm").andAgeEqualTo(231);
            // 标准二与标准一or的关系,did不为空
            empExample.or().andDidIsNotNull();
            List<Emp> empList = empMapper.selectByExample(empExample);
            empList.forEach(emp -> System.out.println(emp));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/84955.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

Go 1.20要来了,看看都有哪些变化-第1篇

前言 Go官方团队在2022.12.08发布了Go 1.20 rc1(release candidate)版本&#xff0c;Go 1.20的正式release版本预计会在2023年2月份发布。 让我们先睹为快&#xff0c;看看Go 1.20给我们带来了哪些变化。(文末有彩蛋&#xff01;) 安装方法&#xff1a; $ go install golan…

[附源码]Nodejs计算机毕业设计基于web的火车订票管理系统Express(程序+LW)

该项目含有源码、文档、程序、数据库、配套开发软件、软件安装教程。欢迎交流 项目运行 环境配置&#xff1a; Node.js Vscode Mysql5.7 HBuilderXNavicat11VueExpress。 项目技术&#xff1a; Express框架 Node.js Vue 等等组成&#xff0c;B/S模式 Vscode管理前后端分…

阅读器消退之际:文石造产品,掌阅塑生态

配图来自Canva可画 阅读器正在变得小众&#xff0c;似乎自Kindle以来营造的那种“阅读的生活方式”&#xff0c;已经被证明是一个伪命题&#xff1a;会阅读的人&#xff0c;无论如何都会去阅读&#xff1b;不会阅读的人&#xff0c;阅读器的归宿终究是一个“泡面盖”。于是&am…

Android原生项目接入flutter_boost4.0

折腾了好几天&#xff0c;经验思维导致的&#xff0c;记录一下踩坑。 官方接入步骤官方文档 接入原生&#xff0c;就3个步骤&#xff0c;我都能折腾好久&#xff0c;浪费时间。 flutter部分很简单&#xff0c;按文档配置就行&#xff0c;在pubspec.yaml依赖就好了。 &#…

Ceph性能瓶颈分析与优化(混合盘篇)

原文链接: Ceph性能瓶颈分析与优化(混合盘篇) - 知乎背景ssdhdd的混合盘场景在各个存储厂商中算是一种典型应用场景。 但是经过测试(4k随机写)发现&#xff0c;加了nvme ssd做ceph的wal和db后&#xff0c;性能提升仅一倍以内且nvme盘性能余量较大。所以希望通过对问题瓶颈进行…

目标检测数据标注案例-高清地图中障碍物(汽车)标注

计算机视觉在无人机中领域中有何作用? 无人机能够在空中识别、分类和追踪目标。无人机的摄像头和感应器可以捕获数据并进行分析&#xff0c;以提取重要信息。 AI可以自动提取视觉数据信息&#xff0c;准确识别、说明和追踪图像和视频中的目标。例如高空检测工作&#xff0c;…

Nacos 配置中心之长轮询--客户端

先来看下长轮询调用的链路 客户端 入口 在 NacosConfigService 初始化的时候,会初始化两个组件 一是网络组件,也就是http数据处理的 (起作用的是 ServerHttpAgent)二是客户端的长轮询ClientWorker public NacosConfigService(Properties properties) throws NacosException…

本地连接docker mysql

1.拉取镜像 docker pull mysql 2.启动mysql实例容器 docker run --name mysql -p 3307:3306 -e MYSQL_ROOT_PASSWORDmysql_pw -d mysql --name 为mysql的实例设置别名。 -p 3307为对外暴露的端口。3306是内部端口 -e MYSQL_ROOT_PASSWORD 设置mysql登录密码 -d 以守…

1.41.5 模型评估和选择,正则化和交叉验证

1.4&1.5 模型评估和选择&#xff0c;正则化和交叉验证模型评估和选择训练误差和测试误差过拟合正则化与交叉验证正则化交叉验证模型评估和选择 训练误差和测试误差 将预测系统的X作为输入&#xff0c;输入到模型里面&#xff0c;就可以得到预测结果。 学习到的模型&…

UNIX网络编程卷一 学习笔记 第五章 TCP客户/服务器程序示例

本章将编写一个完整的TCP客户/服务器程序&#xff0c;这个简单例子是执行以下步骤的一个回射服务器&#xff1a; 1.客户从标准输入读入一行文本&#xff0c;并写给服务器&#xff1b; 2.服务器从网络输入读入这行文本&#xff0c;并回射给客户&#xff1b; 3.客户从网络输入读入…

Spring Ioc 依赖来源-7

1. 依赖查找的来源&#xff1a;除容器内建和自定义Spring Bean之外&#xff0c;还有其他来源提供依赖查找吗&#xff1f; 查找来源 Spring 內建 BeanDefintion Spring 內建单例对象 当spring在注解环境下面, 这个 registerAnnotationConfigProcessors API会被调用, 它会被…

Xilinx Vivado的RTL分析(RTL analysis)、综合(synthesis)和实现(implementation)的区别?

1、一般流程 Xilinx 的开发工具Vivado其实还是比较好上手的&#xff0c;在左边的设计流程导航已经把FPGA的开发过程按先后顺序给排列出来了&#xff1a; Project Manager&#xff1a;项目管理器&#xff0c;此项是对项目的参数进行设置 IP Integrator&#xff1a;IP集成器&…

广域铭岛参编《数智化供应链参考架构》标准正式发布

近日&#xff0c;广域铭岛参编的《数智化供应链参考架构》标准正式发布。该标准由工业互联网产业联盟&#xff08;以下简称“联盟/AII”&#xff09;发布&#xff0c;是国内首个数智化供应链领域的参考架构标准&#xff0c;明确了新兴的数字化和智能化技术如何在供应链领域应用…

大数据进程管理

进程管理 查看进程 进程查看命令 ps la | head -5&#xff0c;能够观察所有系统的数据 ps axjf | head -20&#xff0c;连同部分程序树状态 ps l仅查看自己的bash相关的进程 ps aux观察系统所有进程 属性含义USER进程使用者PID进程标识符%CPU进程使用掉的CPU 资源百分比%MEM…

一个不错的docker支持音频的rdp桌面

docker pull danielguerra/xfce4-rdp-audio 获取该镜像后&#xff0c;运行 docker run -d --name xfce4_0 --shm-size 1g -p 3389:3389 danielguerra/xfce4-rdp-audio相当于开了3个不同的系统容器&#xff0c;端口分别的13389,23389,33389&#xff0c;这时用远程桌面就可以连…

记录--记一次前端CSS升级

这里给大家分享我在网上总结出来的一些知识&#xff0c;希望对大家有所帮助 目前平台前端使用的是原生CSSBEM命名&#xff0c;在多人协作的模式下&#xff0c;容易出现样式冲突。为了减少这一类的问题&#xff0c;提升研效&#xff0c;我调研了业界上主流的7种CSS解决方案&…

Java基于springboot+vue 的传统乐器培训管理系统 elementUI

此网站系统的开发方式和信息管理方式&#xff0c;借鉴前人设计的信息和研发。以在线乐器培训管理为主&#xff0c;以乐器培训管理为核心功能来进行设计和研发&#xff0c;把网站信息和技术整合&#xff0c;开发出一套网上乐器培训管理系统。主要运用现在社会公司中最新的技术框…

rocketmq源码学习-nameServer

前言 最近看了下rocketmq的源码&#xff0c;计划针对最近的学习&#xff0c;做一个笔记&#xff0c;先从nameServer启动的逻辑开始记录吧 在rocketmq中&#xff0c;有四个关键的组件 nameServerbrokerproducerconsumer 这四个组件之间的关系是这样的 关于nameSrv namese…

[附源码]Python计算机毕业设计钓鱼爱好者交流平台Django(程序+LW)

该项目含有源码、文档、程序、数据库、配套开发软件、软件安装教程 项目运行 环境配置&#xff1a; Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术&#xff1a; django python Vue 等等组成&#xff0c;B/S模式 pychram管理等…

老照片修复清晰?父母以前的老照片还能修复吗?

父母结婚时拍摄的结婚照片&#xff0c;现在大概快四十年了&#xff0c;因为保存不善&#xff0c;导致照片泛黄&#xff0c;严重模糊。因为这是父母年轻的时候唯一保留下来的&#xff0c;对我们来说意义重大&#xff0c;所以想要修复照片可以实现吗&#xff1f; 有些照相馆是提…