【Spring】Spring 整合 Junit、MyBatis

news2024/9/29 19:16:06

一、 Spring 整合 Junit

<?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.qiu</groupId>
    <artifactId>spring-015-junit</artifactId>
    <version>1.0-SNAPSHOT</version>

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

    <dependencies>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.3.23</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <!-- Spring6 的支持 junit4 还有 junit5 -->
            <version>5.3.23</version>
        </dependency>
        <!--使用Junit则将下面改为Junit5版本即可-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>
package org.qiu.spring.bean;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author 秋玄
 * @version 1.0
 * @email qiu_2022@aliyun.com
 * @project Spring
 * @package org.qiu.spring.bean
 * @date 2022-11-30-21:55
 * @since 1.0
 */
@Component
public class User {
    @Value("张三")
    private String name;

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                '}';
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public User() {
    }

    public User(String name) {
        this.name = name;
    }
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
    <context:component-scan base-package="org.qiu.spring.bean"/>
</beans>
package org.qiu.spring.test;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.qiu.spring.bean.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

/**
 * @author 秋玄
 * @version 1.0
 * @email qiu_2022@aliyun.com
 * @project Spring
 * @package org.qiu.spring.test
 * @date 2022-11-30-21:56
 * @since 1.0
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration("classpath:spring.xml")
public class JunitTest {

    @Autowired
    private User user;

    @Test
    public void testUser(){
        System.out.println(user.getName());
    }
}

运行效果:  

Spring提供的方便主要是这几个注解:

@RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration("classpath:spring.xml")

在单元测试类上使用这两个注解之后,在单元测试类中的属性上可以使用@Autowired。比较方便

在JUnit5当中,可以使用Spring提供的以下两个注解,标注到单元测试类上,这样在类当中就可以使用@Autowired注解了

@ExtendWith(SpringExtension.class)

@ContextConfiguration("classpath:spring.xml")

二、Spring 集成 MyBatis

1、实验步骤 

  • 第一步:准备数据库表

    • 使用t_act表(账户表)

  • 第二步:IDEA中创建一个模块,并引入依赖

    • spring-context

    • spring-jdbc

    • mysql驱动

    • mybatis

    • mybatis-spring:mybatis提供的与spring框架集成的依赖

    • 德鲁伊连接池

    • junit

  • 第三步:基于三层架构实现,所以提前创建好所有的包

    • com.qiu.bank.mapper

    • com.qiu.bank.service

    • com.qiu.bank.service.impl

    • com.qiu.bank.pojo

  • 第四步:编写pojo

    • Account,属性私有化,提供公开的setter getter和toString。

  • 第五步:编写mapper接口

    • AccountMapper接口,定义方法

  • 第六步:编写mapper配置文件

    • 在配置文件中配置命名空间,以及每一个方法对应的sql。

  • 第七步:编写service接口和service接口实现类

    • AccountService

    • AccountServiceImpl

  • 第八步:编写jdbc.properties配置文件

    • 数据库连接池相关信息

  • 第九步:编写mybatis-config.xml配置文件

    • 该文件可以没有,大部分的配置可以转移到spring配置文件中。

    • 如果遇到mybatis相关的系统级配置,还是需要这个文件。

  • 第十步:编写spring.xml配置文件

    • 组件扫描

    • 引入外部的属性文件

    • 数据源

    • SqlSessionFactoryBean配置

    • 注入mybatis核心配置文件路径

      • 指定别名包

      • 注入数据源

    • Mapper扫描配置器

      • 指定扫描的包

    • 事务管理器DataSourceTransactionManager

      • 注入数据源

    • 启用事务注解

      • 注入事务管理器

  • 第十一步:编写测试程序,并添加事务,进行测试

2、具体实现 

<?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.qiu</groupId>
    <artifactId>spring-016-sm</artifactId>
    <version>1.0-SNAPSHOT</version>

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

    <dependencies>
        <!--spring-context-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>5.3.23</version>
        </dependency>
        <!--spring-jdbc-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>5.3.23</version>
        </dependency>
        <!--mysql驱动-->
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>8.0.30</version>
        </dependency>
        <!--mybatis-->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.5.10</version>
        </dependency>
        <!--mybatis-spring:mybatis提供的与spring框架集成的依赖-->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>2.0.3</version>
        </dependency>
        <!--德鲁伊连接池-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.2.15</version>
        </dependency>
        <!--junit-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>
package org.qiu.spring.pojo;

/**
 * @author 秋玄
 * @version 1.0
 * @email qiu_2022@aliyun.com
 * @project Spring
 * @package org.qiu.spring.pojo
 * @date 2022-12-01-09:16
 * @since 1.0
 */
public class Account {
    private String actno;
    private Double balance;

    public Account() {
    }

    public Account(String actno, Double balance) {
        this.actno = actno;
        this.balance = balance;
    }

    @Override
    public String toString() {
        return "Account{" +
                "actno='" + actno + '\'' +
                ", balance=" + balance +
                '}';
    }

    public String getActno() {
        return actno;
    }

    public void setActno(String actno) {
        this.actno = actno;
    }

    public Double getBalance() {
        return balance;
    }

    public void setBalance(Double balance) {
        this.balance = balance;
    }
}
package org.qiu.spring.mapper;

import org.qiu.spring.pojo.Account;

import java.util.List;

/**
 * 实现类不需要写,由 mybatis 通过动态代理实现即可
 * @author 秋玄
 * @version 1.0
 * @email qiu_2022@aliyun.com
 * @project Spring
 * @package org.qiu.spring.mapper
 * @date 2022-12-01-09:17
 * @since 1.0
 */
public interface AccountMapper {
    int insert(Account account);
    int delete(String atcno);
    int update(Account account);
    Account selectByActno(String actno);
    List<Account> selectAll();
}
<?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="org.qiu.spring.mapper">
    <insert id="insert">
        insert into t_act values (#{actno},#{balance})
    </insert>

    <delete id="delete">
        delete from t_act where actno = #{actno}
    </delete>

    <update id="update">
        update t_act set balance = #{balance} where actno = #{actno}
    </update>

    <select id="selectByActno" resultType="Account">
        select * from t_act where actno = #{actno}
    </select>

    <select id="selectAll" resultType="Account">
        select * from t_act
    </select>
</mapper>
package org.qiu.spring.service;

import org.qiu.spring.pojo.Account;

import java.util.List;

/**
 * @author 秋玄
 * @version 1.0
 * @email qiu_2022@aliyun.com
 * @project Spring
 * @package org.qiu.spring.service
 * @date 2022-12-01-09:30
 * @since 1.0
 */
public interface AccountService {

    int save(Account account);

    int deleteByActno(String actno);

    int modify(Account account);

    Account getByActno(String actno);

    List<Account> getAll();

    void transfer(String fromAccount,String toAccount,Double money);
}
package org.qiu.spring.service.impl;

import org.qiu.spring.mapper.AccountMapper;
import org.qiu.spring.pojo.Account;
import org.qiu.spring.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 秋玄
 * @version 1.0
 * @email qiu_2022@aliyun.com
 * @project Spring
 * @package org.qiu.spring.service.impl
 * @date 2022-12-01-09:33
 * @since 1.0
 */
@Service("accountService")
public class AccountServiceImpl implements AccountService {

    @Autowired
    private AccountMapper accountMapper;

    @Override
    public int save(Account account) {
        return accountMapper.insert(account);
    }

    @Override
    public int deleteByActno(String actno) {
        return accountMapper.delete(actno);
    }

    @Override
    public int modify(Account account) {
        return accountMapper.update(account);
    }

    @Override
    public Account getByActno(String actno) {
        return accountMapper.selectByActno(actno);
    }

    @Override
    public List<Account> getAll() {
        return accountMapper.selectAll();
    }

    @Override
    public void transfer(String fromAccount, String toAccount, Double money) {
        Account from = accountMapper.selectByActno(fromAccount);

        if (from.getBalance() < money) {
            throw new RuntimeException("余额不足");
        }

        Account to = accountMapper.selectByActno(toAccount);

        from.setBalance(from.getBalance() - money);
        to.setBalance(to.getBalance() + money);

        int count = accountMapper.update(from);
        count += accountMapper.update(to);

        if (count != 2){
            throw new RuntimeException("转账失败");
        }
    }
}
jdbc.driver=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/mvc
jdbc.username=root
jdbc.password=mysql
<?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>
    <!--打印 mybatis 日志信息-->
    <settings>
        <setting name="logImpl" value="STDOUT_LOGGING"/>
    </settings>
</configuration>
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
                           http://www.springframework.org/schema/beans/spring-beans.xsd
                           http://www.springframework.org/schema/context
                           https://www.springframework.org/schema/context/spring-context.xsd
                           http://www.springframework.org/schema/tx
                           http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!--组件扫描-->
    <context:component-scan base-package="org.qiu.spring"/>

    <!--引入外部属性文件-->
    <context:property-placeholder location="jdbc.properties"/>

    <!--数据源-->
    <bean id="dataSuorce" class="com.alibaba.druid.pool.DruidDataSource">
        <property name="driverClassName" value="${jdbc.driver}"/>
        <property name="url" value="${jdbc.url}"/>
        <property name="username" value="${jdbc.username}"/>
        <property name="password" value="${jdbc.password}"/>
    </bean>

    <!--SqlSessionFactoryBean-->
    <bean class="org.mybatis.spring.SqlSessionFactoryBean">
        <!--注入数据源-->
        <property name="dataSource" ref="dataSuorce"/>
        <!--指定 mybatis 核心配置文件-->
        <property name="configLocation" value="mybatis-config.xml"/>
        <!--指定别名包-->
        <property name="typeAliasesPackage" value="org.qiu.spring.pojo"/>
    </bean>

    <!--Mapper扫描配置器,扫描Mapper接口,生成代理类-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="org.qiu.spring.mapper"/>
    </bean>

    <!--事务管理器-->
    <bean id="txManaget" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSuorce"/>
    </bean>

    <!--启动事务注解-->
    <tx:annotation-driven transaction-manager="txManaget"/>

</beans>

由于使用了事务,所以需要给service添加事务注解  

@Transactional
@Service("accountService")
public class AccountServiceImpl implements AccountService {
	\\ ......
}

import org.junit.Test;
import org.qiu.spring.service.AccountService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author 秋玄
 * @version 1.0
 * @email qiu_2022@aliyun.com
 * @project Spring
 * @package PACKAGE_NAME
 * @date 2022-12-01-10:04
 * @since 1.0
 */
public class SMTest {

    @Test
    public void testSM(){
        ApplicationContext app = new ClassPathXmlApplicationContext("spring.xml");
        AccountService service = app.getBean("accountService", AccountService.class);
        try {
            service.transfer("act001","act002",10000.0);
            System.out.println("转账成功");
        } catch (Exception e){
            e.printStackTrace();
        }
    }

}

运行效果:  

Logging initialized using 'class org.apache.ibatis.logging.stdout.StdOutImpl' adapter.
十二月 01, 2022 10:16:27 上午 com.alibaba.druid.support.logging.JakartaCommonsLoggingImpl info
信息: {dataSource-1} inited
Creating a new SqlSession
Registering transaction synchronization for SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f666ebb]
JDBC Connection [com.mysql.cj.jdbc.ConnectionImpl@15a04efb] will be managed by Spring
==>  Preparing: select * from t_act where actno = ?
==> Parameters: act001(String)
<==    Columns: actno, balance
<==        Row: act001, 40000.0
<==      Total: 1
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f666ebb]
Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f666ebb] from current transaction
==>  Preparing: select * from t_act where actno = ?
==> Parameters: act002(String)
<==    Columns: actno, balance
<==        Row: act002, 10000.0
<==      Total: 1
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f666ebb]
Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f666ebb] from current transaction
==>  Preparing: update t_act set balance = ? where actno = ?
==> Parameters: 30000.0(Double), act001(String)
<==    Updates: 1
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f666ebb]
Fetched SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f666ebb] from current transaction
==>  Preparing: update t_act set balance = ? where actno = ?
==> Parameters: 20000.0(Double), act002(String)
<==    Updates: 1
Releasing transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f666ebb]
Transaction synchronization committing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f666ebb]
Transaction synchronization deregistering SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f666ebb]
Transaction synchronization closing SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@2f666ebb]
转账成功

3、Spring 配置文件的 import

spring 配置文件有多个,并且可以在 spring 的核心配置文件中使用 import 进行引入,我们可以将组件扫描单独定义到一个配置文件中,如下:  

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd 
                           http://www.springframework.org/schema/context 
                           https://www.springframework.org/schema/context/spring-context.xsd">

    <!--组件扫描-->
    <context:component-scan base-package="com.qiu.bank"/>

</beans>

然后在核心配置文件中引入:  

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context" 
       xmlns:tx="http://www.springframework.org/schema/tx"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                           http://www.springframework.org/schema/beans/spring-beans.xsd 
                           http://www.springframework.org/schema/context 
                           https://www.springframework.org/schema/context/spring-context.xsd 
                           http://www.springframework.org/schema/tx 
                           http://www.springframework.org/schema/tx/spring-tx.xsd">

    <!--引入其他的spring配置文件-->
    <import resource="common.xml"/>

</beans>

注意:在实际开发中,service单独配置到一个文件中,dao单独配置到一个文件中,然后在核心配置文件中引入,养成好习惯  

一  叶  知  秋,奥  妙  玄  心

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

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

相关文章

Wallace树乘法器及Verilog实现

一、Wallace树乘法器 Wallace树乘法器就是将多个部分积进行分组&#xff0c;每三个一组&#xff0c;最后如果剩下的部分积个数不够三个的不做处理&#xff0c;然后将各组的部分积进行相加得到和以及进位信息&#xff0c;直到最终只剩下两行部分积&#xff0c;相加后得到最终结…

作为网络安全工程师需要掌握的安全小知识!

网络安全风险无处不在&#xff0c;今天为大家梳理了一些网络安全相关的小知识&#xff0c;希望能进一步提升大家的安全意识&#xff0c;帮助大家建立更加安全的网络环境。 一、主机电脑安全 1、操作系统安全&#xff1a;安装操作系统时需要选择合适的版本&#xff0c;及时打补…

RabbitMQ高级(MQ的问题,消息可靠性,死信交换机,惰性队列,MQ集群)【详解】

目录 一、MQ的问题 1. 问题说明 2. 准备代码环境 1 创建project 2 创建生产者模块 3 创建消费者模块 二、消息可靠性 1. 介绍 2. 生产者确认机制 3. MQ消息持久化 4. 消费者确认机制 5. 消费者auto模式的失败重试 6. 小结 三、死信交换机和延迟消息 1. 介绍 2. …

李彦宏回顾大模型重构百度这一年

“大模型我们走在最前面&#xff0c;我们需要去勇闯无人区&#xff0c;需要去冒前人没有冒过的风险。”近日&#xff0c;在百度一场内部颁奖活动中&#xff0c;百度创始人、董事长兼首席执行官李彦宏指出&#xff0c;百度一直坚信技术可以改变世界&#xff0c;会一直沿着这条路…

【Web】CTFSHOW 七夕杯 题解

目录 web签到 easy_calc easy_cmd web签到 CTF中字符长度限制下的命令执行 rce(7字符5字符4字符)汇总_ctf中字符长度限制下的命令执行 5个字符-CSDN博客7长度限制直接梭了 也可以打临时文件RCE import requestsurl "http://4ae13f1e-8e42-4afa-a6a6-1076acd08211.c…

学习笔记——字符串(单模+多模+练习题)

单模匹配 Brute Force算法&#xff08;暴力&#xff09; 算法思想 母串和模式串字符依次配对&#xff0c;如果配对成功则继续比较后面位置是否相同&#xff0c;如果出现匹配不成功的位置&#xff0c;则j&#xff08;模式串当前的位置&#xff09;从头开始&#xff0c;i&…

【JavaScript】内置对象 - 数组对象 ⑤ ( 数组转字符串 | toString 方法 | join 方法 )

文章目录 一、数组转字符串1、数组转字符串 ( 逗号分割 ) - toString()2、数组转字符串 ( 自定义分割符 ) - join() Array 数组对象参考文档 : https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Array 一、数组转字符串 1、数组转字符串 ( 逗…

每日一练 2024.5.10

题目&#xff1a; 给定一个非负整数数组 nums&#xff0c; nums 中一半整数是 奇数 &#xff0c;一半整数是 偶数 。 对数组进行排序&#xff0c;以便当 nums[i] 为奇数时&#xff0c;i 也是 奇数 &#xff1b;当 nums[i] 为偶数时&#xff0c; i 也是 偶数 。 示例 1&#…

景联文科技:用高质量数据采集标注赋能无人机技术,引领无人机迈入新纪元!

随着无人机技术的不断发展与革新&#xff0c;它已成为现代社会中一个前景无限的科技领域。 无人机应用领域 边境巡逻与安防&#xff1a;边境管理部门利用无人机监控边境线&#xff0c;防止非法越境和其他安全威胁&#xff0c;同时也能监控地面安保人员的工作状态和行动路线。 …

双目相机标定流程(MATLAB)

一&#xff1a;经典标定方法 1.1OPENCV 1.2ROS ROS进行双目视觉标定可以得到左右两个相机的相机矩阵和畸变系数&#xff0c;如果是单目标定&#xff0c;用ROS会非常方便。 3.MATLAB标定&#xff08;双目标定&#xff09; MATLAB用来双目标定会非常方便&#xff0c;主要是为…

【oj题】环形链表

目录 一. OJ链接&#xff1a; 环形链表 【思路】 快慢指针 ​编辑【扩展问题】 为什么快指针每次走两步&#xff0c;慢指针走一步可以解决问题&#xff1f; ​编辑【扩展问题】快指针一次走3步&#xff0c;走4步&#xff0c;...n步行吗&#xff1f; 二. OJ链接&#xff1a…

2024年第九届“数维杯”大学生数学建模挑战赛B题

第一个问题为&#xff1a;正己烷不溶物对热解产率是否产生显著影响&#xff1f; 第一个问题&#xff1a;正己烷不溶物(INS)对热解产率是否产生显著影响&#xff1f; 解析&#xff1a;正己烷不溶物(INS)主要是由生物质和煤中的非挥发性物质组成&#xff0c;它们在共热解过程中会…

Django 静态文件管理与部署指南

title: Django 静态文件管理与部署指南 date: 2024/5/10 17:38:36 updated: 2024/5/10 17:38:36 categories: 后端开发 tags: WebOptCDN加速DjangoCompressWebpackStaticDeployCICD-ToolsSecStatic 第一章&#xff1a;介绍 Django 静态文件的概念和重要性 在 Web 开发中&a…

【Docker】Docker部署Java程序

Maven中使用打包插件 <build><finalName>duanjian</finalName><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId><configuration><mainClass…

一次完整的GC流程

Java堆中内存区分 Java的堆由新生代&#xff08;Young Generation&#xff09;和老年代&#xff08;Old Generation&#xff09;组成。新生代存放新分配的对象&#xff0c;老年代存放长期存在的对象。 新生代&#xff08;Young&#xff09;由年轻区&#xff08;Eden&a…

Blender细节补充

1.饼状菜单&#xff0c;用于快速切换/选择 例如&#xff1a; ~&#xff1a;切换视图 Z&#xff1a;切换着色方式 &#xff0c;&#xff1a;切换坐标系 .&#xff1a;切换基准点 Shift S&#xff1a;吸附 有两种使用方式&#xff1a; -点选 -滑选&#xff0c;按快捷键…

手机一键换ip地址到湖南

怎么把手机ip改成湖南&#xff1f;想要手机一键换ip地址到湖南&#xff0c;可以试试使用虎观代理app&#xff0c;一键操作&#xff0c;简单又方便。你会惊讶地发现&#xff0c;更改手机IP至湖南竟然如此便捷。 选用APP优势&#xff1a; ★IP资源丰富 已经在国内各大省份提供服…

Fastapi+docker+tortoise-orm+celery

因为项目是后期引入celery,所以导致构建docker的时候只有fastapi的项目&#xff0c;celery的重启比较麻烦 1.docker安装celery pip install celery安装celery的时候注意python版本与celery版本的适配&#xff0c;有些celery的版本不支持python的版本&#xff0c;具体的版本请看…

泰迪智能科技携手新乡学院开展“泰迪智能双创工作室”共建交流会

为深化校企合作&#xff0c;实现应用型人才培养目标。5月8日&#xff0c;广东泰迪智能科技股份有限公司河南分公司市场总监张京瑞到访新乡学院数学与统计学院参观交流&#xff0c;数学与统计学院院长赵国喜、副院长皮磊、张秦&#xff0c;教研室主任许寿方、姚广出席本次交流会…

【基础算法总结】二分查找一

二分查找一 1. 二分查找2.在排序数组中查找元素的第一个和最后一个位置3.x 的平方根4.搜索插入位置 点赞&#x1f44d;&#x1f44d;收藏&#x1f31f;&#x1f31f;关注&#x1f496;&#x1f496; 你的支持是对我最大的鼓励&#xff0c;我们一起努力吧!&#x1f603;&#x1…