手写mybatis-预编译sql语句

news2024/11/19 20:31:41

sql表 mybatis数据库中的gxa_user表

/*
 Navicat Premium Data Transfer

 Source Server         : root
 Source Server Type    : MySQL
 Source Server Version : 80028
 Source Host           : localhost:3306
 Source Schema         : mybatis

 Target Server Type    : MySQL
 Target Server Version : 80028
 File Encoding         : 65001

 Date: 05/06/2024 20:48:12
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for gxa_user
-- ----------------------------
DROP TABLE IF EXISTS `gxa_user`;
CREATE TABLE `gxa_user`  (
  `id` bigint(0) NOT NULL AUTO_INCREMENT,
  `username` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `password` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `salt` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `phone` varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `created` datetime(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0),
  `last_login_time` datetime(0) NULL DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP(0),
  `status` int(0) NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 47 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;

-- ----------------------------
-- Records of gxa_user
-- ----------------------------
INSERT INTO `gxa_user` VALUES (1, '强哥', 'RbWEEsXVVxiR765qwusODQ==', 'e46d82f4-66b1-457d-8e70-36232b0a656e', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (2, '张老师', 'RbWEEsXVVxiR765qwusODQ==', 'e46d82f4-66b1-457d-8e70-36232b0a656e', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (3, '王国强', 'RbWEEsXVVxiR765qwusODQ==', 'e46d82f4-66b1-457d-8e70-36232b0a656e', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (11, '噗噗', '123456', '111', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (16, '噗噗2', '123456', '111', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (17, '补补', '123456', '111', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (20, '补补', '123456', '111', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (21, 'map', '8888', '222', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (23, 'map', '8888', '222', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (28, '123456', '12345', '123455', '123456', '2024-06-03 21:45:15', '2024-06-03 21:45:15', 1);
INSERT INTO `gxa_user` VALUES (29, 'gxaUser', '12345', '123455', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (30, 'mybatis', '12345', '123455', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (31, 'mybatis', '12345', '123455', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (32, 'mybatis', '12345', '123455', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (33, 'mybatisdemo', '123456', '11', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (34, 'mybatisdemo', '123456', '11', '123456789', '2024-06-03 21:42:18', '2024-06-03 21:42:18', 1);
INSERT INTO `gxa_user` VALUES (35, 'mybatisdemo', '123456', '11', '123568', '2024-06-03 21:47:49', '2024-06-03 21:47:49', 1);
INSERT INTO `gxa_user` VALUES (36, 'mybatisdemo', '123456', '11', '123568', '2024-06-03 21:50:22', '2024-06-03 21:50:22', 1);
INSERT INTO `gxa_user` VALUES (42, 'mybatis', '12345', '123455', '1234556', '2024-06-03 22:02:47', NULL, 1);
INSERT INTO `gxa_user` VALUES (43, 'mybatis', '12345', '123455', '1234556', '2024-06-03 22:04:07', '2024-06-03 22:04:07', 1);
INSERT INTO `gxa_user` VALUES (44, 'mybatis', '12345', '123455', '1234556', '2024-06-03 22:06:07', '2024-06-03 22:06:07', 1);
INSERT INTO `gxa_user` VALUES (45, 'mybatis', '12345', '123455', '1234556', '2024-06-05 14:38:22', '2024-06-05 14:38:22', 1);
INSERT INTO `gxa_user` VALUES (46, 'mybatis', '12345', '123455', '1234556', '2024-06-05 16:15:04', '2024-06-05 16:15:04', 1);

SET FOREIGN_KEY_CHECKS = 1;

jdbc.properties

jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://127.0.0.1:3306/mybatis?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
jdbc.username=root
jdbc.password=123456

准备四个注解放在annotation包里面

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Delete {
    String value() default "";
}
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Insert {
    String value() default "";
}
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Select {
    String value() default "";
}
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Update {
    String value() default "";
}

配置数据库连接以及事务

import com.alibaba.druid.pool.DruidDataSource;

import javax.sql.DataSource;
import java.io.IOException;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

public class JdbcUtils {
    public static DataSource dataSource;
    public static Properties properties=new Properties();
    public static ThreadLocal<Connection> threadLocal=new ThreadLocal<>();

    static {
        try {
            InputStream resourceAsStream = JdbcUtils.class.getClassLoader().getResourceAsStream("jdbc.properties");
            properties.load(resourceAsStream);
            DruidDataSource druidDataSource = new DruidDataSource();
            druidDataSource.setDriverClassName(properties.getProperty("jdbc.driver"));
            druidDataSource.setUrl(properties.getProperty("jdbc.url"));
            druidDataSource.setUsername(properties.getProperty("jdbc.username"));
            druidDataSource.setPassword(properties.getProperty("jdbc.password"));
            dataSource=druidDataSource;
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
    public static Connection getConnection(){
        try {
            if (threadLocal.get()==null)
                threadLocal.set(dataSource.getConnection());
                return threadLocal.get();
        } catch (SQLException e) {
            e.printStackTrace();
            throw new RuntimeException(e);
        }
    }
    public static void close(){
        if (threadLocal.get()!=null){
            try{
                threadLocal.get().close();
            }catch (Exception e){
                e.printStackTrace();
                throw new RuntimeException("连接关闭失败");
            }
            threadLocal.set(null);
        }
    }
    public static void rollback(){
        if(threadLocal.get()!=null){
            try{
                threadLocal.get().rollback();
            }catch (Exception e){
                e.printStackTrace();
                throw new RuntimeException("回滚失败");
            }
        }

    }
    public static void commit(){
        if (threadLocal.get()!=null){
            try{
                threadLocal.get().commit();
            }catch (Exception e){
                e.printStackTrace();
                throw new RuntimeException("提交失败");
            }

        }

    }
    public static void start(){

            try{
                getConnection().setAutoCommit(false);
            }catch (Exception e){
                e.printStackTrace();
                throw new RuntimeException("开启事务失败");
            }


    }

}

根据上面的表创建javabean实体类

/**
 * (GxaUser)实体类
 *
 * @author makejava
 * @since 2024-05-24 15:16:19
 */
public class GxaUser{
    
    private Long id;
    
    private String username;
    
    private String password;
    
    private String salt;
    
    private String phone;
    
    private LocalDateTime created;
    
    private LocalDateTime last_login_time;
    
    private Integer status;


    public Long getId() {
        return id;
    }

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

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public LocalDateTime getCreated() {
        return created;
    }

    public void setCreated(LocalDateTime created) {
        this.created = created;
    }

    public LocalDateTime getLastLoginTime() {
        return last_login_time;
    }

    public void setLastLoginTime(LocalDateTime lastLoginTime) {
        this.last_login_time = lastLoginTime;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Override
    public String toString() {
        return "GxaUser{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", salt='" + salt + '\'' +
                ", phone='" + phone + '\'' +
                ", created=" + created +
                ", lastLoginTime=" + last_login_time +
                ", status=" + status +
                '}';
    }
}

Dto传输参数给数据库的

public class GxaUserDto {

    
    private String username;
    
    private String password;
    
    private String salt;
    
    private String phone;
    
    private Date created;
    
    private Date last_login_time;
    
    private Integer status;



    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getSalt() {
        return salt;
    }

    public void setSalt(String salt) {
        this.salt = salt;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Date getCreated() {
        return created;
    }

    public void setCreated(Date created) {
        this.created = created;
    }

    public Date getLastLoginTime() {
        return last_login_time;
    }

    public void setLastLoginTime(Date lastLoginTime) {
        this.last_login_time = lastLoginTime;
    }

    public Integer getStatus() {
        return status;
    }

    public void setStatus(Integer status) {
        this.status = status;
    }

    @Override
    public String toString() {
        return "GxaUser{" +
                " username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", salt='" + salt + '\'' +
                ", phone='" + phone + '\'' +
                ", created=" + created +
                ", lastLoginTime=" + last_login_time +
                ", status=" + status +
                '}';
    }
}

mapper接口类

import com.ssj.annotation.Delete;
import com.ssj.annotation.Insert;
import com.ssj.annotation.Select;
import com.ssj.annotation.Update;
import com.ssj.entity.GxaUser;
import com.ssj.entity.GxaUserDto;
import com.ssj.entity.GxaUserDto2;

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

public interface GxaUserMapper {
    @Select("Select * from gxa_user where id=?")
    GxaUser findUserById(Long id);
    @Select("Select * from gxa_user")
    List<GxaUser> findUser();
    @Insert("Insert into gxa_user(username,password,salt,phone,created,last_login_time,status)\n" +
            "        values(?,?,?,?,?,?,?)")
    int insertUser(GxaUserDto user);
    @Update("update gxa_user set username=? where id=?")
    int update(String username,Long id);
    @Delete("Delete from gxa_user where id=?")
    int delete(Long id);
}

jdk动态地理实现上面mapper接口

import com.ssj.annotation.Delete;
import com.ssj.annotation.Insert;
import com.ssj.annotation.Select;
import com.ssj.annotation.Update;

import java.lang.reflect.*;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.util.ArrayList;
import java.util.List;

public class MybatisUtils {
    public static <T> T getMapper(Class<T> clazz) {
        return (T) Proxy.newProxyInstance(clazz.getClassLoader(), new Class[]{clazz}, new InvocationHandler() {
            @Override
            public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                System.out.println("该 " + method.getName() + " 方法被调用了");
                if (method.isAnnotationPresent(Insert.class)) {
                    Insert annotation = method.getAnnotation(Insert.class);
                    String sql = annotation.value();
                    return executeInsert(sql, args);
                } else if (method.isAnnotationPresent(Delete.class)) {
                    Delete annotation = method.getAnnotation(Delete.class);
                    String sql = annotation.value();
                    return executeUpdate(sql, args);
                } else if (method.isAnnotationPresent(Update.class)) {
                    Update annotation = method.getAnnotation(Update.class);
                    String sql = annotation.value();
                    return executeUpdate(sql, args);
                } else if (method.isAnnotationPresent(Select.class)) {
                    Select annotation = method.getAnnotation(Select.class);
                    String sql = annotation.value();
                    return executeQuery(sql, args, method);
                }
                return null;
            }

            private int executeInsert(String sql, Object[] args) throws Exception {
                if (args.length == 0) {
                    System.out.println("args长度为0");
                    throw new IllegalArgumentException("Invalid argument for insert operation");
                }

                try (Connection connection = JdbcUtils.getConnection();
                     PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
                    JdbcUtils.start();
                    setPreparedStatementParameters(preparedStatement, args[0]);

                    int rows = preparedStatement.executeUpdate();
                    JdbcUtils.commit();
                    return rows;
                }catch (Exception e){
                    JdbcUtils.rollback();
                    JdbcUtils.commit();
                    e.printStackTrace();
                    throw new RuntimeException("数据库连接异常");
                }finally {
                    JdbcUtils.close();
                }
            }
            private int executeUpdate(String sql, Object[] args) throws Exception {
                try (Connection connection = JdbcUtils.getConnection();
                     PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
                    JdbcUtils.start();
                    for (int i = 0; i < args.length; i++) {
                        System.out.println("修改参数: " + args[i]);
                        preparedStatement.setObject(i + 1, args[i]);
                    }

                    int rows = preparedStatement.executeUpdate();
                    JdbcUtils.commit();
                    return rows;
                } catch (Exception e) {
                    JdbcUtils.rollback();
                    throw e;
                } finally {
                    JdbcUtils.close();
                }
            }


            // 执行查询操作
            private Object executeQuery(String sql, Object[] args, Method method) throws Exception {
                try (Connection connection = JdbcUtils.getConnection();
                     PreparedStatement preparedStatement = connection.prepareStatement(sql)) {
                    System.out.println("args.length="+args);
                    if (args!=null){
                        // 设置PreparedStatement参数
                        for (int i = 0; i < args.length; i++) {
                            // 将方法参数设置到PreparedStatement中
                            preparedStatement.setObject(i + 1, args[i]);
                        }
                    }
                    // 执行查询操作
                    ResultSet resultSet = preparedStatement.executeQuery();

                    // 获取方法的返回类型
                    Class<?> returnType = method.getReturnType();
                    // 如果返回类型是List,则将结果集映射为List对象
                    if (returnType == List.class) {
                        return mapResultSetToList(resultSet, getGenericReturnType(method));
                    } else {
                        // 如果不是List,则将结果集映射为单个对象
                        if (resultSet.next()) {
                            return mapResultSetToObject(resultSet, returnType);
                        }
                    }
                    return null;
                }catch (Exception e){
                    e.printStackTrace();
                    throw new RuntimeException("数据库连接异常");
                }finally {
                    JdbcUtils.close();
                }
            }

            private void setPreparedStatementParameters(PreparedStatement preparedStatement, Object param) throws Exception {
                System.out.println(param);
                Class<?> clazz = param.getClass();
                Field[] fields = clazz.getDeclaredFields();
                int index = 1;

                for (Field field : fields) {
                    field.setAccessible(true);
                    Object value = field.get(param);
                    System.out.println("insert--- 参数:"+value);
//                    if (value==null) continue;
                    preparedStatement.setObject(index++, value);
                }
            }



            // 将ResultSet映射为对象列表
            private <T> List<T> mapResultSetToList(ResultSet resultSet, Class<T> clazz) throws Exception {
                List<T> list = new ArrayList<>();
                // 遍历结果集,将每行数据映射为对象并添加到列表中
                while (resultSet.next()) {
                    list.add(mapResultSetToObject(resultSet, clazz));
                }
                return list;
            }

            // 将ResultSet映射为单个对象
            private <T> T mapResultSetToObject(ResultSet resultSet, Class<T> clazz) throws Exception {
                T obj = clazz.getDeclaredConstructor().newInstance();
                ResultSetMetaData metaData = resultSet.getMetaData();
                // 遍历结果集的元数据,将每列的数据映射到对象的相应字段中
                for (int i = 1; i <= metaData.getColumnCount(); i++) {
                    String columnName = metaData.getColumnName(i);
                    Field field = clazz.getDeclaredField(columnName);
                    field.setAccessible(true);
                    field.set(obj, resultSet.getObject(i));
                }
                return obj;
            }

            // 获取方法的泛型返回类型
            private Class<?> getGenericReturnType(Method method) {
                Type returnType = method.getGenericReturnType();
                // 如果返回类型是参数化类型,则获取实际的类型参数
                if (returnType instanceof ParameterizedType) {
                    ParameterizedType parameterizedType = (ParameterizedType) returnType;
                    return (Class<?>) parameterizedType.getActualTypeArguments()[0];
                }
                return Object.class;
            }
        });
    }
}

在这里插入图片描述

项目结构

在这里插入图片描述

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

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

相关文章

图解DSPy:Prompt的时代终结者?!

大模型技术论文不断&#xff0c;每个月总会新增上千篇。本专栏精选论文重点解读&#xff0c;主题还是围绕着行业实践和工程量产。若在某个环节出现卡点&#xff0c;可以回到大模型必备腔调重新阅读。而最新科技&#xff08;Mamba&#xff0c;xLSTM,KAN&#xff09;则提供了大模…

Windows Linux下查看静态库,动态库各种命令的总结

Windows环境下查看库文件 静态库(.lib) 使用lib.exe查看库内容 命令示例:lib /list C.lib使用dumpbin.exe查看库的详细信息 命令示例:dumpbin /headers C.lib动态链接库(.dll) 使用dumpbin.exe查看DLL的导出信息 命令示例:dumpbin /exports B.dll

选择富唯智能的可重构装配系统,就是选择了一个可靠的合作伙伴

在数字化、智能化的浪潮中&#xff0c;制造业正迎来一场前所未有的变革。而在这场变革中&#xff0c;富唯智能凭借其卓越的技术实力和创新能力&#xff0c;成为引领行业发展的领军企业。选择富唯智能的可重构装配系统&#xff0c;就是选择了一个可靠的合作伙伴&#xff0c;共同…

注册用户超6亿,哈啰发布年度可持续发展暨ESG报告

6月5日&#xff0c;哈啰发布《2023年度可持续发展暨ESG报告》&#xff0c;深入全面地展示2023年哈啰在可持续发展领域的举措和阶段性成果。 报告显示&#xff0c;哈啰始终遵循健康可持续的商业模式&#xff0c;以科技创新推动出行进化&#xff0c;在促进行业发展、环境友好、社…

Spring Boot 应用打 WAR 包后无法注册到 Nacos怎么办

你好&#xff0c;我是柳岸花开。 在微服务架构中&#xff0c;服务注册与发现是至关重要的一环。Nacos 作为阿里巴巴开源的注册中心&#xff0c;能够很好地满足这一需求。然而&#xff0c;在将 Spring Boot 应用打包成 WAR 部署到外部服务器时&#xff0c;可能会遇到服务无法注册…

【C++奇妙冒险】日期类Date的实现

文章目录 前言日期类Date的接口设计构造函数和打印函数获取日期并判断日期是否合法日期类的大小比较关系<运算符重载 判断小于运算符重载 判断相等<运算符重载 判断小于等于>运算符重载 判断大于> 运算符重载 判断大于等于! 运算符重载 不等于 日期类计算日期天数日…

WordPress 插件推荐:菜单缓存插件——Menu Caching

今天在缙哥哥博客上发现了一个 WordPress 速度优化插件的优化感觉很不错&#xff0c;明月自己装上也体验了一番&#xff0c; WordPress 菜单的载入速度无论是 PC 端和移动端都非常不错&#xff0c;并且这个叫 Menu Caching 的菜单缓存插件还完美的兼容 WPRocket&#xff0c;W3 …

现代园区管理工具:“园区运营管理平台”全景解析!

当下&#xff0c;我国各地区产业园区、工业园区、经济开发区、科技园区、商务园区如雨后春笋般迅速崛起&#xff0c;成为推动区域经济增长、促进产业升级的重要载体。然而&#xff0c;如何高效、智能地管理这些园区&#xff0c;提高这些园区的运营效率、服务质量和综合竞争力&a…

AI办公自动化:用kimi批量提取音频中的标题并重命名

很多音频文件&#xff0c;文件名很乱&#xff0c;需要根据音频信息中的标题聪明吗 在kimi中输入提示词&#xff1a; 你是一个Python编程专家&#xff0c;一步步的思考&#xff0c;完成以下脚本的撰写&#xff1a; 打开文件夹&#xff1a;E:\有声\a16z播客 读取里面所有的mp3格…

文件夹如何加密码?这4个文件夹加密方法值得一试!

文件夹如何加密码&#xff1f;在与朋友、家人和同事共享同一电脑计算机时&#xff0c;您可能有一些不希望他们查看的重要或机密文件。那么如何避免这种情况呢&#xff1f;使用密码保护锁定文件和文件夹可以提高你的数字隐私和安全性&#xff0c;因为这意味着你需要输入密码才能…

【React篇 】React项目中常用的工具库

我们可以从项目初始化、开发、构建、检查及发布的顺序总结react项目开发常用的工具库。 首先是初始化。 初始化工程项目一般用官方维护的 create-react-app&#xff0c;这个工具使用起来简单便捷&#xff0c;但 create-react-app 的配置隐藏比较深&#xff0c;修改配置时搭配…

重学java 64.IO流 字符流

Action speak louder than words —— 24.6.5 字符输入流 一、字节流读取中文的问题 1.注意&#xff1a; 字节流是万能流&#xff0c;这个万能更侧重于文件复制&#xff0c;但是尽量不要边读边看 2.原因&#xff1a; UTF-8&#xff1a;一个汉字占三个字节 GBK&#xff1a;一…

Tomcat相关概述和部署

目录 一、Tomcat知识 1.Tomcat概述 2.Tomcat组件构成 3.Tomcat 功能组件结构 4.Tomcat的请求过程 二、tomcat服务部署 1.老样子准备工作——关闭防火墙和selinux&#xff0c;防止其对安装过程的干扰 2.将准备好的软件包拖入/opt目录下&#xff0c;进行安装JDK 3.设置J…

【iOS】UI学习——UITableView

UI学习&#xff08;四&#xff09; UITableView基础UITableView协议UITableView高级协议和单元格 UITableView基础 dateSource:数据代理对象 delegate:普通代理对象 numberOfSectionInTableView:获得组数协议 numberOfRowsInSection:获得行数协议 cellForRowAtIndexPath:创建单…

引擎:Shader

一、原理 创建Shader脚本&#xff0c;创建材质球&#xff0c;将物体的渲染效果Shader脚本挂载到材质球&#xff0c;最后把材质球挂到3d物体上面从而实现渲染。 二、模型边缘发光 原理&#xff1a;正对着摄像机的模型三角面边缘光最弱&#xff0c;垂直于摄像机的模型三角面边缘光…

算法金 | 10 大必知的自动化机器学习库(Python)

大侠幸会&#xff0c;在下全网同名[算法金] 0 基础转 AI 上岸&#xff0c;多个算法赛 Top [日更万日&#xff0c;让更多人享受智能乐趣] 一、入门级自动化机器学习库 1.1 Auto-Sklearn 简介&#xff1a; Auto-Sklearn 是一个自动机器学习库&#xff0c;基于 Python 的 scikit…

python自动获取网站关闭清单脚本

1.网站关闭清单 2.网站关闭脚本 02nginx_close.sh #!/bin/bash#echo "13 test.com" #ssh root192.168.120.145 "/data/shells/02nginx_close.sh > /dev/null 2>&1 &"#echo "14 test1.com" #ssh root192.168.179.5 "/data/s…

【python】 ModuleNotFoundError: No module named datasets

成功解决“ModuleNotFoundError: No module named datasets”错误的全面指南 在Python编程中&#xff0c;遇到ModuleNotFoundError: No module named datasets这样的错误通常意味着Python解释器无法找到名为datasets的模块。datasets是一个流行的Python库&#xff0c;常用于加载…

通信技术振幅键控(ASK)调制与解调硬件实验

一、实验目的 1. 掌握用键控法产生ASK信号的方法&#xff1b; 2. 掌握ASK非相干解调的原理。 二、实验内容 1. 观察ASK已调信号的波形&#xff1b; 2. 观察ASK解调信号的波形。 三、实验器材 1. 双踪示波器&#xff1b; 2. 通信原理实验箱信号源模块、③、④、⑦号模块。…

JVM之【字节码/Class文件/ClassFile 内容解析】

说在前面的话 Java语言:跨平台的语言(write once,run anywhere) 当Java源代码成功编译成字节码后&#xff0c;如果想在不同的平台上面运行&#xff0c;则无须再次编译这个优势不再那么吸引人了。Python、PHP、Perl、Ruby、Lisp等有强大的解释器。跨平台似乎已经快成为一门语言…