简化java代码:mapstruct + 策略模式

news2024/9/23 7:28:20

目录

目的

准备

注意

相同类型-属性名不同

实体类 

映射

使用

验证-查看实现类

测试

不同类型(策略模式)

 实体类

映射

工具类

使用:对象拷贝

验证-查看实现类

测试

使用:集合拷贝

测试

策略模式说明

准备-依赖


目的

简化 BeanUtils.copyProperties 属性对拷代码,自动生成空判断,结合策略模式自定义转换

集合对拷:一行代码就能完成以前 先new,再 for循环,再add的多行代码,而且也不用判空

准备

这里我将开发中经常用到的全部依赖都列举出来(若下载不下来依赖,将settings.xml替换成我博客存档的那一份),此处为了不影响观看,放在文章末尾处。

注意

写好转换之后,maven 记得 clean install,查看一下生成的实现类有没有问题

实现类在  target 里面,若target没有,执行下列操作

相同类型-属性名不同

将 下面 Doctor 中的  i1  s1  分别转给 DoctorDto 中的  i2  s2

实体类 

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Doctor {
    private int id;
    private String name;
    String s1;
    int i1;
}
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DoctorDto {
    private int id;
    private String name;
    private String s2;
    private int i2;
}

映射

@Mapper(componentModel = "spring")
public interface BeanConvert {

    BeanConvert INSTANCE = Mappers.getMapper(BeanConvert.class);

    /**
     * 不一致的属性映射
     */
    @Mappings({
            @Mapping(target = "i2", source = "i1"),
            @Mapping(target = "s2", source = "s1")
    })
    DoctorDto toDto(Doctor doctor);
}

使用

    @GetMapping("/test")
    public DoctorDto get() {
        Doctor doctor = new Doctor();
        doctor.setId(1);
        doctor.setName("张三");
        doctor.setI1(1);
        doctor.setS1("1");
        return BeanConvert.INSTANCE.toDto(doctor);
    }

验证-查看实现类

clean install  重启

测试

可以看到 i1,s1中的值已经过来了

不同类型(策略模式)

 实体类

将下面 Sku2 中的  Long date  Integer code  分别转给 SkuDTO2 中的  Date date  String value

 一个是时间戳转换,一个是枚举转换

@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
public class Sku2 {
    Long skuId;
    String skuCode;
    String skuPrice;
    List<String> nameList;
    Long date;
    Integer code;
}
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
public class SkuDTO2 {
    Long skuId;
    String skuCode;
    String skuPrice;
    List<String> nameList;
    Date date;
    String value;
}

映射

uses 定义了两个策略,一个负责转换时间戳,一个负责转换枚举

@Mapper(componentModel = "spring", uses = {TimeConvertStrategy.class, EnumConvertStrategy.class})
public interface BeanConvert {

    /**
     * 策略模式测试
     */
    @Mapping(target = "value", source = "code")
    SkuDTO2 domain2Dto(Sku2 sku2);

}
@Component
public class EnumConvertStrategy {

    public String convert(Integer code) {
        return MyEnum.getByCode(code);
    }
    
}
@Component
public class TimeConvertStrategy {

    public Date date2TimeStamp(Long timeStamp) {
        if (timeStamp == null) {
            return null;
        }
        return new Date(timeStamp);
    }
    
}
public enum MyEnum {
    A(1,"哈哈"),B(2,"呵呵");

    private final Integer code;
    private final String msg;

    MyEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }

    public static String getByCode(Integer code) {
        if (code == null) {
            return null;
        }
        for (MyEnum value : MyEnum.values()) {
            if (value.getCode().equals(code)) {
                return value.getMsg();
            }
        }
        return null;
    }
    
}

工具类

这里使用工具类,主要是辅助容器中的bean初始化的,包括我们定义的策略的初始化

/**
 * ApplicationContextAware 接口可以让 Bean 获取到 ApplicationContext 对象
 * 通过这个对象,可以获取 Spring 容器中的其他 Bean实例 或一些组件
 */
@Component
public class ConvertSupport implements ApplicationContextAware {

    private static BeanConvert beanConvert;

    /**
     * 启动的时候,直接获取到 beanConvert 的实例
     */
    @Override
    public void setApplicationContext(ApplicationContext context) throws BeansException {
        // 这里如果没有执行,说明没有注入容器,但是我有了@Component注解,说明其未生效,主启动类@ComponentScan指定一下
        if (beanConvert == null) {
            beanConvert = context.getBean(BeanConvert.class);
            System.out.println("执行过这里");
        }
    }

    /**
     * 列表转换
     */
    public static <I, O> List<O> copyList(List<I> inputList, BiFunction<BeanConvert, I, O> function) {
        if (CollectionUtils.isEmpty(inputList)) {
            return Collections.emptyList();
        }
        List<O> resultList = new ArrayList<>(inputList.size());
        for (I input : inputList) {
            resultList.add(function.apply(beanConvert, input));
        }
        return resultList;
    }

    /**
     * bean to bean
     */
    public static <I, O> O castBean(I input, BiFunction<BeanConvert, I, O> function) {
        return function.apply(beanConvert, input);
    }


}

使用:对象拷贝

    @GetMapping("/test2")
    public SkuDTO2 get2() {
        Sku2 sku2 = new Sku2();
        sku2.setSkuId(1L);
        sku2.setSkuCode("2");
        sku2.setNameList(Lists.newArrayList("测", "试"));
        sku2.setDate(new Date().getTime());
        sku2.setCode(1);
        return ConvertSupport.castBean(sku2, BeanConvert::domain2Dto);
    }

验证-查看实现类

clean install  重启

测试

使用:集合拷贝

    @GetMapping("/test3")
    public List<DoctorDto> get3() {
        List<Doctor> list = Lists.newArrayList(
                new Doctor(1, "张三", "1", 1),
                new Doctor(2, "李四", "2", 2),
                new Doctor(3, "王五", "3", 3));
        return ConvertSupport.copyList(list, BeanConvert::toDto);
    }

此后,一行代码就能完成以前 先new,再 for循环,再add的多行代码,而且也不用判空

测试

策略模式说明

上面使用的是用来处理不同类型,平常去除 if else 的使用方式:

先定义两个 策略,和上面类似,spring管理后,通过策略内部判断决定怎么走,方法再抽象出一层

/**
 * 策略1
 */
@Component
public class Situation1 implements Situation {

    private static final String value = "用户传过来的值为1";

    /**
     * 判断进入哪个策略(if)
     */
    @Override
    public Boolean judge(String val) {
        return value.equals(val);
    }

    /**
     * 逻辑处理
     */
    @Override
    public int logic(int a, int b) {
        return a + b;
    }
}
/**
 * 策略2
 */
@Component
public class Situation2 implements Situation {
    private static final String value = "用户传过来的值为2";

    /**
     * 判断进入哪个策略(if)
     */
    @Override
    public Boolean judge(String val) {
        return value.equals(val);
    }

    /**
     * 逻辑处理
     */
    @Override
    public int logic(int a, int b) {
        return a - b;
    }
}
public interface Situation {
    /**
     * 判断进入哪个策略(if)
     */
    Boolean judge(String val);

    /**
     * 逻辑处理
     */
    int logic(int a, int b);
}
@RestController
public class StrategyTest {

    @Autowired
    private ApplicationContext applicationContext;

    @GetMapping("/test/st")
    public void test() {
        String value = "用户传过来的值为2";
        Map<String, Situation> beans = applicationContext.getBeansOfType(Situation.class);
        beans.forEach((k, Strategy) -> {
            // 判断用户传过来的值,从而决定进入哪个策略
            if (Strategy.judge(value)) {
                int num = Strategy.logic(8, 2);
                System.out.println(num);
            }
        });
    }
}

准备-依赖

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.mytest</groupId>
    <artifactId>springboot-demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>springboot-demo</name>
    <description>springboot-demo</description>
    <properties>
        <org.mapstruct.version>1.5.0.RC1</org.mapstruct.version>
        <org.projectlombok.version>1.18.22</org.projectlombok.version>
        <lombok-mapstruct-binding.version>0.2.0</lombok-mapstruct-binding.version>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--HuTool为我们提供的一些便捷工具。-->
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>4.1.14</version>
        </dependency>
        <!--Valid-->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
            <version>2.3.2.RELEASE</version>
        </dependency>
        <!--自定义注解-->
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>2.0.1.Final</version>
        </dependency>
        <!-- 定时任务 -->
        <dependency>
            <groupId>org.quartz-scheduler</groupId>
            <artifactId>quartz</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>com.mchange</groupId>
                    <artifactId>c3p0</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- 解析客户端操作系统、浏览器等 -->
        <dependency>
            <groupId>eu.bitwalker</groupId>
            <artifactId>UserAgentUtils</artifactId>
            <version>1.21</version>
        </dependency>
        <!-- pagehelper 分页插件 注意 pagehelper 和 spring-boot-starter-parent 版本,容易出现循环依赖 一般通过加@Lazy解决,这里通过版本号解决-->
        <dependency>
            <groupId>com.github.pagehelper</groupId>
            <artifactId>pagehelper-spring-boot-starter</artifactId>
            <version>1.4.1</version>
        </dependency>
        <!--HttpUtils需要的所有依赖-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.15</version>
        </dependency>

        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>
        <!--mybatisplus-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-boot-starter</artifactId>
            <version>3.4.1</version>
        </dependency>
        <!--DateTime 需要的依赖,由于没有版本号管理,如果不写version,上面有一处会爆红-->
        <dependency>
            <groupId>joda-time</groupId>
            <artifactId>joda-time</artifactId>
            <version>2.9.4</version>
        </dependency>
        <!--代码生成器-->
        <dependency>
            <groupId>com.baomidou</groupId>
            <artifactId>mybatis-plus-generator</artifactId>
            <version>3.4.1</version>
        </dependency>
        <!--velocity模板引擎-->
        <dependency>
            <groupId>org.apache.velocity</groupId>
            <artifactId>velocity-engine-core</artifactId>
            <version>2.3</version>
        </dependency>

        <!-- easyexcel依赖 -->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>easyexcel</artifactId>
            <version>3.0.5</version>
        </dependency>

        <dependency>
            <groupId>cn.afterturn</groupId>
            <artifactId>easypoi-base</artifactId>
            <version>4.3.0</version>
        </dependency>

        <dependency>
            <groupId>cn.afterturn</groupId>
            <artifactId>easypoi-web</artifactId>
            <version>4.3.0</version>
        </dependency>

        <dependency>
            <groupId>cn.afterturn</groupId>
            <artifactId>easypoi-annotation</artifactId>
            <version>4.3.0</version>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.1.16</version>
        </dependency>

        <!--Lists.partition 需要的依赖-->
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>25.1-jre</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>io.lettuce</groupId>
                    <artifactId>lettuce-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--        &lt;!&ndash;jedis,redis客户端&ndash;&gt;-->
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
        </dependency>
        <!--        &lt;!&ndash;使用redisson作为所有分布式锁,分布式对象等功能框架,也可以使用springboot的方式,就不用自己@Configuration了&ndash;&gt;-->
        <dependency>
            <groupId>org.redisson</groupId>
            <artifactId>redisson</artifactId>
            <version>3.13.3</version>
        </dependency>

        <!--mysql驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.17</version>
        </dependency>
        <dependency>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct</artifactId>
            <version>${org.mapstruct.version}</version>
        </dependency>

        <!-- 特别注意 mapstruct 和 lombok 的顺序,顺序出问题,实现类就不映射了 -->
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>${org.projectlombok.version}</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-lang3</artifactId>
            <version>3.10</version>
        </dependency>
        <!--CollectionUtils依赖-->
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.2</version>
        </dependency>
        <dependency>
            <groupId>com.google.code.google-collections</groupId>
            <artifactId>google-collect</artifactId>
            <version>snapshot-20080530</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

        <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-log4j12 -->
<!--        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
        </dependency>-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>transmittable-thread-local</artifactId>
            <version>2.11.5</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>21.0</version>
        </dependency>
        <dependency>
            <groupId>javax.persistence</groupId>
            <artifactId>persistence-api</artifactId>
            <version>1.0</version>
        </dependency>
        <!--注意:3.0.0 版本   http://localhost:8081/swagger-ui.html   页面可能登陆不上去-->
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger2</artifactId>
            <version>2.9.2</version>
        </dependency>
        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.9.2</version>
        </dependency>
    </dependencies>

    <!-- 特别注意 mapstruct 和 lombok 的顺序,顺序出问题,实现类就不映射了 -->
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${org.projectlombok.version}</version>
                        </path>
                        <!-- This is needed when using Lombok 1.18.16 and above -->
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok-mapstruct-binding</artifactId>
                            <version>${lombok-mapstruct-binding.version}</version>
                        </path>
                        <!-- Mapstruct should follow the lombok path(s) -->
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${org.mapstruct.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                    <include>**/*.yml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                    <include>**/*.yml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

</project>

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

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

相关文章

如何降低微服务复杂度丨云栖大会微服务主题分享实录

作者&#xff1a;谢吉宝 本文整理自阿里云资深技术专家、中间件负责人谢吉宝在2023云栖大会《极简微服务模式&#xff0c;降低微服务复杂度的最佳实践》的分享 2023 云栖大会现场 当面临复杂的挑战时&#xff0c;"分而治之"的方法往往能取得显著的效果。微服务架构…

室外全彩LED显示屏尺寸与设计考量

在现代城市的建筑景观中&#xff0c;室外全彩LED显示屏以其鲜艳丰富的色彩和强大的视觉冲击力成为一种不可忽视的存在。然而&#xff0c;如何确定室外全彩LED显示屏的尺寸以及常见的尺寸比例是一个需要综合考虑多个因素的问题。 尺寸的确定与内容相关 首先&#xff0c;对于图文…

LabVIEW工业机器人系统

介绍了ABB工业机器人与LabVIEW之间进行数据交互的解决方案。通过使用TCP/IP协议的socket通信&#xff0c;实现了机器人坐标数据的读取&#xff0c;为人机交互提供了一个更便捷、更高效的新思路。 系统主要由ABB工业机器人、基于TCP/IP协议的通信接口和LabVIEW软件组成。工业机…

2023年第十六届中国系统架构师大会(SACC2023):核心内容与学习收获(附大会核心PPT下载)

大会以“数字转型 架构演进”为主题&#xff0c;聚焦系统架构在数字化转型中的演进和应用。 与往届相比&#xff0c;本届大会最大的变化是从原来的大会演讲模式变革为专题研讨会模式。专题研讨会主题内容紧扣行业落地实践痛点与难点&#xff0c;多角度聚焦行业的架构演进之路。…

基于Apache httpd为windows11搭建代理服务器

文章目录 一.概述二.检查电脑系统类型三.下载安装Apache Httpd四.代理服务配置五.代理服务安装六.报错解决方法七.测试是否运行成功7.1 本机测试7.2 局域网代理测试 八.设置特定ip可访问&#xff08;阻止其他ip访问&#xff09;九.参考文档 一.概述 出于某些原因&#xff0c;我…

如何使用phpStudy软件测试本地PHP及环境搭建

各位同学朋友们大家好&#xff01;我是咕噜铁蛋&#xff01;我们经常需要在本地进行PHP代码的开发和测试。而phpStudy作为一个集成了Apache、MySQL和PHP的软件套装&#xff0c;提供了方便快捷的环境搭建和测试工具。今天铁蛋为大家详细介绍如何使用phpStudy来测试本地PHP及环境…

Unity中URP下获取每一个额外灯数据

文章目录 前言一、我们先来看一下 SimpleLit 中的调用二、获取额外灯索引1、非移动平台2、非GLES平台3、大多数平台 三、获取额外灯数据 前言 在上一篇文章中&#xff0c;我们知道了URP下是怎么获取额外灯数量的。 Unity中URP下获取额外灯数量 在这篇文章中&#xff0c;我们…

Geogebra绘制正态分布曲线-学习b站何威老师视频

​ 参考资料 GeoGebra系列教程3——GGB与正态分布密度曲线_哔哩哔哩_bilibili 我要开始学习啦&#xff0c;吼吼~~~ 准备工作 https://www.geogebra.org/download 选择GeoGebra 经典 6 详细步骤 设计思路具体操作设计积分区间【a,b】创建滑动条a∈[-5,5]&#xff0c;增量是…

Linux 下查看端口以及释放端口

目录 一、查看端口是否被占用 1、使用 netstat 命令 2、使用 lsof 命令 二、释放端口 1、使用kill命令 2、使用 fuser 命令 三、netstat 四、lsof 五、fuser 一、查看端口是否被占用 在 Linux 系统上&#xff0c;你可以使用 netstat 或 lsof 命令来查看端口是否被占用。…

Goodbye! Xshell、iTerm2、FinalShell,mobaxterm,新一代开源免费的终端工具真香!

前言 众所周知&#xff0c;在数字化时代&#xff0c;远程连接成为工作和管理中不可或缺的一环。 而在这个领域&#xff0c;SSH&#xff08;Secure Shell&#xff09;一直是最常用的协议之一&#xff0c;为远程管理提供了安全的通信渠道。 然而&#xff0c;伴随着技术的发展和…

flutter tab页面切换练手,手势滑动、禁止滑动、page切换动画,禁止切换动画。

1&#xff1a;AppBar、TabBar、TabBarView实现页面切换&#xff0c;点击tab后tabBarView有左右切换动画&#xff0c;滑动page联动tabBar class DevicePage extends StatefulWidget {const DevicePage({super.key});overrideState<DevicePage> createState() > _Devic…

热门技术问答 | 请 GaussDB 用户查收

近年来&#xff0c;Navicat 与华为云 GaussDB 展开一系列技术合作&#xff0c;为 GaussDB 用户提供面向管理开发工具的生态工具。Navicat 现已完成 GaussDB 主备版&#xff08;单节点、多节点&#xff09;和分布式数据库的多项技术对接。Navicat 通过工具的流畅性和实用性&…

[蓝桥杯]真题讲解:景区导游(DFS遍历、图的存储、树上前缀和与LCA)

蓝桥杯真题讲解&#xff1a; 一、视频讲解二、暴力代码三、正解代码 一、视频讲解 视频讲解 二、暴力代码 //暴力代码&#xff1a;DFS #include<bits/stdc.h> #define endl \n #define deb(x) cout << #x << " " << x << \n; #de…

初识计算机网络 | 计算机网络的发展 | 协议初识

1.计算机网络的发展 “矛盾是普遍存在的&#xff0c;矛盾是事物联系的实质内容和事物发展的根本动力&#xff01;” 计算机在诞生之初&#xff0c;在军事上用来计算导弹的弹道轨迹&#xff01;在发展的过程中&#xff08;商业的推动&#xff0c;国家政策推动&#xff09;&…

嵌入式linux学习之系统烧录

1.所需文件 1. 开发板为正点原子stm32mp157,文件可按照linux驱动教程编译&#xff0c;也可在正点原子文档->08、系统镜像\02、出厂系统镜像中找到&#xff1a; 2.烧录 1.拨码开关为000(usb启动)&#xff0c;otg接口接入虚拟机&#xff0c;打开stm32cubeProgrammer: 2.页面…

2023年跨界融合创新应用合作发展大会:核心内容与学习收获(附大会核心PPT下载)

2023年跨界融合创新应用合作发展大会&#xff0c;主要聚焦于跨界融合和创新应用&#xff0c;旨在促进不同行业之间的交流与合作&#xff0c;推动各行业的创新发展。 会议主要围绕以下主题展开&#xff1a; 1、跨界融合&#xff1a;会议探讨不同行业之间的融合模式和合作方式&…

绝地求生:PUBG服务条款修订,是否因为PLAYERUNKNOWN礼包导致?

嗨&#xff0c;我是闲游盒~ PUBG全球的官网&#xff0c;刚刚更新了一条《PUBG: 绝地求生》。 通知内容大概如下 对所有平台的PUBG的服务条款进行修订&#xff0c;修订安排于2月7日后生效。 从修订的条款内容猜测&#xff0c;本次修订安排是因为PLAYERUNKNOWN礼包 记得预约荣…

【轮式平衡机器人】——TMS320F28069片内外设之GPIO

引入 接下来的几期博客会介绍轮式平衡机器人TMS320F28069片内外设&#xff0c;了解片内外设的基本原理&#xff0c;内容较为基础&#xff0c;都是些简单的simulink模型&#xff0c;旨在将复杂的原理过渡到simulink软件应用。足够了解的博友可跳过。 后续还将会结合MATLAB/Sim…

26、江科大stm32视频学习笔记——I2C读写W25Q64

一、W25Q64简介 1、W25Q64的内存空间结构: 一页256字节&#xff0c;4K(4096 字节)为一个扇区&#xff0c;16个扇区为1块&#xff0c;容量为8M字节&#xff0c;共有128个块&#xff0c;2048 个扇区。 2、W25Q64每页大小由256字节组成&#xff0c;每页的256字节用一次页编程指…

排序算法经典模型: 梯度提升决策树(GBDT)的应用实战

目录 一、Boosting训练与预测 二、梯度增强的思想核心 三、如何构造弱学习器和加权平均的权重 四、损失函数 五、梯度增强决策树 六、GBDT生成新特征 主要思想 构造流程 七、梯度增强决策树以及在搜索的应用 7.1 GDBT模型调参 7.1.1 框架层面参数 n_estimators su…