SSM:Spring + Spring MVC + MyBatis 的整合

news2024/10/4 23:47:33

SSM

  • 前言
  • 整合

在这里插入图片描述

前言

在完成 Spring 、Spring MVC 与 MyBatis 基础知识的学习后,下面简单介绍 SSM 框架的整合使用。

整合

SSM,是 Java 开发中常用的一个 Web 框架组合,用于构建基于 Spring 和 MyBatis 的 Web 应用( Spring MVC 是 Spring 框架的扩展)。

简单示例:
首先,创建一个 Maven 工程( Web 项目)后,在 pom.xml 中添加依赖

<dependencies>
  <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>compile</scope>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.3.25</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.springframework/spring-web -->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-web</artifactId>
    <version>5.3.25</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.springframework/spring-webmvc -->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-webmvc</artifactId>
    <version>5.3.25</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.springframework/spring-tx -->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-tx</artifactId>
    <version>5.3.25</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.springframework/spring-aspects -->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-aspects</artifactId>
    <version>5.3.25</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.springframework/spring-orm -->
  <dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-orm</artifactId>
    <version>5.3.25</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
  <dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
  </dependency>

  <!-- https://mvnrepository.com/artifact/javax.servlet.jsp/javax.servlet.jsp-api -->
  <dependency>
    <groupId>javax.servlet.jsp</groupId>
    <artifactId>javax.servlet.jsp-api</artifactId>
    <version>2.3.3</version>
    <scope>provided</scope>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-api -->
  <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>2.0.6</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-nop -->
  <dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-nop</artifactId>
    <version>2.0.6</version>
    <type>jar</type>
  </dependency>

  <!-- https://mvnrepository.com/artifact/commons-logging/commons-logging -->
  <dependency>
    <groupId>commons-logging</groupId>
    <artifactId>commons-logging</artifactId>
    <version>1.2</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-impl -->
  <dependency>
    <groupId>org.apache.taglibs</groupId>
    <artifactId>taglibs-standard-impl</artifactId>
    <version>1.2.5</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.apache.taglibs/taglibs-standard-spec -->
  <dependency>
    <groupId>org.apache.taglibs</groupId>
    <artifactId>taglibs-standard-spec</artifactId>
    <version>1.2.5</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
  <dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.25</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/com.mchange/c3p0 -->
  <dependency>
    <groupId>com.mchange</groupId>
    <artifactId>c3p0</artifactId>
    <version>0.9.5.2</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis -->
  <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>3.5.6</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.mybatis.generator/mybatis-generator-core -->
  <dependency>
    <groupId>org.mybatis.generator</groupId>
    <artifactId>mybatis-generator-core</artifactId>
    <version>1.4.0</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.mybatis/mybatis-spring -->
  <dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    <version>2.0.6</version>
  </dependency>

  <!-- https://mvnrepository.com/artifact/org.mybatis.caches/mybatis-ehcache -->
  <dependency>
    <groupId>org.mybatis.caches</groupId>
    <artifactId>mybatis-ehcache</artifactId>
    <version>1.2.1</version>
  </dependency>

  <dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper</artifactId>
    <version>5.3.2</version>
  </dependency>
</dependencies>

<!--   UserMapper.xml 配置文件写在 src 找不到问题解决方案     -->
<build>
  <resources>
    <resource>
      <!-- directory:指定资源文件的位置 -->
      <directory>src/main/java</directory>
      <includes>
        <!-- “**”:表示任意级目录    “*”:表示任意任意文件 -->
        <!-- mvn resources:resources :对资源做出处理,先于 compile 阶段  -->
        <include>**/*.properties</include>
        <include>**/*.xml</include>
      </includes>
      <!--  filtering:开启过滤,用指定的参数替换 directory 下的文件中的参数(eg. ${name}) -->
      <filtering>false</filtering>
    </resource>
    <resource>
      <directory>src/main/resources</directory>
    </resource>
  </resources>
</build>

项目结构如图:
在这里插入图片描述

接着,在 webapp/WEB-INF 目录下的 web.xml 配置文件中,对 spring 和 springmvc 进行初始化配置

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd"
         version="4.0">

  <!-- 配置整个 web 应用的初始化参数,指定 spring 的配置文件所在位置 -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:spring.xml</param-value>
  </context-param>
  <!-- spring 与 javaweb 应用的整合 -->
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <!-- 配置前端控制器 dispatcherServlet -->
  <servlet>
    <servlet-name>dispatcherServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

    <!-- 配置 springmvc 的配置文件所在位置 -->
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>classpath:springmvc.xml</param-value>
    </init-param>
    <!-- 配置初始化参数,启动时创建 servlet 对象 -->
    <load-on-startup>1</load-on-startup>
  </servlet>

  <!-- 配置url地址 -->
  <servlet-mapping>
    <servlet-name>dispatcherServlet</servlet-name>
    <!-- 根目录下所有地址,其他 servlet 除外 -->
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

同时,在 resources 目录下创建 spring.xml 和 springmvc.xml 配置文件,并且进行相关配置

<?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"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
       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 http://www.springframework.org/schema/aop https://www.springframework.org/schema/aop/spring-aop.xsd http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring.xsd">

    <!-- spring.xml -->
    <!-- 指定排除扫描 Controller 和 ControllerAdvice 包,避免与 springmvc 扫描重复 -->
    <context:component-scan base-package="cn.edu.ssmdemo">
        <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" />
        <context:exclude-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice" />
    </context:component-scan>

    <!-- 在 Bean 的外部属性文件的使用中有所提及 -->
    <!-- 使用context命名空间,通过 location 属性指定 properties 文件位置 -->
    <context:property-placeholder location="classpath:jdbc.properties" />
    <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
        <!-- 连接MySQL数据库的基本信息的配置 -->
        <!-- 驱动程序类名:com.mysql.jdbc.Driver -->
        <property name="driverClass" value="${jdbc.driverClass}" />
        <!-- JDBC URL:jdbc:mysql://<host>:<port>/<database_name> -->
        <property name="jdbcUrl" value="${jdbc.url}" />
        <!-- 数据库用户名 -->
        <property name="user" value="${jdbc.user}" />
        <!-- 数据库用户密码 -->
        <property name="password" value="${jdbc.password}" />
        <!-- 若数据库中的连接数量不足时,向数据库申请的连接数量 -->
        <property name="acquireIncrement" value="${acquireIncrement}" />
        <!-- 初始化数据库连接池时连接的数量 -->
        <property name="initialPoolSize" value="${initialPoolSize}" />
        <!-- 数据库连接池最小的数据库连接数 -->
        <property name="minPoolSize" value="${minPoolSize}" />
        <!-- 数据库连接池最大的数据库连接数 -->
        <property name="maxPoolSize" value="${maxPoolSize}" />
        <!-- C3P0数据库连接池可以维护的Statement数量 -->
        <property name="maxStatements" value="${maxStatements}" />
        <!-- 每个连接同时可以使用Statement的数量 -->
        <property name="maxStatementsPerConnection" value="${maxStatementsPerConnection}" />
    </bean>

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

    <!-- 配置事务属性 -->
    <tx:advice id="txAdvice" transaction-manager="dataSourceTransactionManager" >
        <tx:attributes>
            <tx:method name="get*" read-only="true"/>
            <tx:method name="load*" read-only="true"/>
            <tx:method name="find*" read-only="true"/>
            <tx:method name="select*" read-only="true"/>
            <tx:method name="*" read-only="false"/>
        </tx:attributes>
    </tx:advice>

    <!-- 配置事务切入点 -->
    <aop:config>
        <aop:pointcut id="txPointcut" expression="execution(* cn.edu.ssmdemo.service.*.*(..))" />
        <aop:advisor advice-ref="txAdvice" pointcut-ref="txPointcut" />
    </aop:config>

    <!-- 配置 mybatis 整合 -->
    <bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean" >
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation" value="classpath:mybatis.xml" />
        <property name="mapperLocations" value="classpath:cn/edu/ssmdemo/mapper/*.xml" />
    </bean>

    <mybatis-spring:scan base-package="cn.edu.ssmdemo.mapper" />
</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:mvc="http://www.springframework.org/schema/mvc"
       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/mvc
       https://www.springframework.org/schema/mvc/spring-mvc.xsd">

    <!-- springmvc.xml -->
    <!-- 指定只扫描 Controller 和 ControllerAdvice 包 -->
    <context:component-scan base-package="cn.edu.ssmdemo" use-default-filters="false">
        <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" />
        <context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice" />
    </context:component-scan>

    <mvc:annotation-driven />

    <!-- 配置 springmvc 视图解析器 -->
    <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <!-- 配置视图页面 -->
        <property name="prefix" value="/WEB-INF/views/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>

    <!-- 配置自动识别静态资源 -->
    <mvc:default-servlet-handler />
</beans>

另外,在 spring.xml 配置文件中,还要相应文件的创建与配置。在 resources 目录下再创建 jdbc.properties 资源文件和 mybatis.xml 配置文件,并且进行相关配置

jdbc.driverClass=com.mysql.cj.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/ssmdemo?useSSL=false&serverTimezone=UTC
jdbc.user=root
jdbc.password=0123
acquireIncrement=5
initialPoolSize=10
minPoolSize=5
maxPoolSize=100
maxStatements=2
maxStatementsPerConnection=5
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC
        "-//mybatis.org//DTD Config 3.0//EN"
        "https://mybatis.org/dtd/mybatis-3-config.dtd">

<!-- mybatis.xml 配置文件 -->
<configuration>

    <settings>
        <!-- 懒加载配置 -->
        <setting name="lazyLoadingEnabled" value="true"/>
        <setting name="aggressiveLazyLoading" value="false"/>

        <!-- 开启二级缓存 -->
        <setting name="cacheEnabled" value="true"/>
    </settings>

    <!-- typeAliases:设置别名,简化类型名称的书写。用一个别名代替一个类全名 -->
    <typeAliases>
        <package name="cn.edu.ssmdemo.model" />
    </typeAliases>

    <!-- plugins 标签需要在 environments 标签前 -->
    <plugins>
        <plugin interceptor="com.github.pagehelper.PageInterceptor"></plugin>
    </plugins>
</configuration>

然后,在 resources 目录下创建一个 Generator 的配置文件 mybatis_generator.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>

    <context id="DB2Tables" targetRuntime="MyBatis3">

        <commentGenerator>
            <!-- 是否去除自动生成的注释 -->
            <property name="suppressAllComments" value="true" />
        </commentGenerator>

        <!-- MySQL数据库连接的信息:驱动类、连接地址、用户名、密码 -->
        <jdbcConnection driverClass="com.mysql.cj.jdbc.Driver"
                        connectionURL="jdbc:mysql://localhost:3306/ssmdemo?useUnicode=true&amp;characterEncoding=utf8&amp;useSSL=false&amp;serverTimezone=UTC"
                        userId="root"
                        password="0123" >
            <property name="nullCatalogMeansCurrent" value="true" />
        </jdbcConnection>

        <!-- Java 类型解析器,一般默认为 false -->
        <javaTypeResolver>
            <property name="forceBigDecimals" value="false" />
        </javaTypeResolver>

        <!-- Domain 生成器:生成实体类。属性 targetProject :生成 POJO 类的位置;其余默认 -->
        <javaModelGenerator targetPackage="cn.edu.ssmdemo.model" targetProject=".\src\main\java" />

        <!-- Mapping 生成器:生成映射文件。属性 targetProject :mapper 映射文件生成的位置;其余默认 -->
        <sqlMapGenerator targetPackage="cn.edu.ssmdemo.mapper" targetProject=".\src\main\java">
            <!-- enableSubPackages :是否让 schema 作为包的后缀 -->
            <property name="enableSubPackages" value="true" />
        </sqlMapGenerator>

        <!-- Mapper 生成器:生成接口。targetProject 属性:mapper 接口生成的的位置 -->
        <javaClientGenerator type="XMLMAPPER" targetPackage="cn.edu.ssmdemo.mapper" targetProject=".\src\main\java">
            <!-- enableSubPackages :是否让 schema 作为包的后缀 -->
            <property name="enableSubPackages" value="true" />
        </javaClientGenerator>

        <!-- 指定数据表。tableName 属性:指定数据库的表名;domainObjectName 属性:生成对应实体类的名字;...Example 属性:设置关闭即可 -->
        <table tableName="user"
               domainObjectName="User"
               enableCountByExample="false"
               enableUpdateByExample="false"
               enableDeleteByExample="false"
               enableSelectByExample="false"
               selectByExampleQueryId="false" />
    </context>

</generatorConfiguration>

再在 MySQL 数据库 ssmdemo 中,创建数据表 user
表结构信息如图:
在这里插入图片描述

随之,在 test 目录下创建 RunSSMGenerator 类,通过数据库表结构自动生成对应的实体类、DAO 接口和 SQL 映射文件

package cn.edu.ssmdemo.test;

import org.junit.Test;
import org.mybatis.generator.api.MyBatisGenerator;
import org.mybatis.generator.config.Configuration;
import org.mybatis.generator.config.xml.ConfigurationParser;
import org.mybatis.generator.exception.InvalidConfigurationException;
import org.mybatis.generator.exception.XMLParserException;
import org.mybatis.generator.internal.DefaultShellCallback;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class RunSSMGenerator {
    @Test
    public void mbgTest() throws IOException, XMLParserException, InvalidConfigurationException, SQLException, InterruptedException {
        List<String> warnings = new ArrayList<String>();
        boolean overwrite = true;

        // 只需修改 Generator 的配置文件名称即可
        String path = this.getClass().getClassLoader().getResource("mybatis_generator.xml").getPath();
        File configFile = new File(path);

        ConfigurationParser cp = new ConfigurationParser(warnings);
        Configuration config = cp.parseConfiguration(configFile);
        DefaultShellCallback callback = new DefaultShellCallback(overwrite);
        MyBatisGenerator myBatisGenerator = new MyBatisGenerator(config, callback, warnings);
        myBatisGenerator.generate(null);
    }
}

运行生成实体类、DAO 接口和 SQL 映射文件后,接下来只实现 selectByPrimaryKey(Integer id) 方法作为简单的演示:
1.在 service 层创建接口 UserService

package cn.edu.ssmdemo.service;

import cn.edu.ssmdemo.model.User;

//简单示例
public interface UserService {
    User selectByPrimaryKey(Integer id);
}

2.在 service 层创建接口实现类 UserServiceImpl

package cn.edu.ssmdemo.service;

import cn.edu.ssmdemo.mapper.UserMapper;
import cn.edu.ssmdemo.model.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("userService")
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    @Override
    public User selectByPrimaryKey(Integer id) {
        return userMapper.selectByPrimaryKey(id);
    }
}

3.在 controller 层创建 UserController 类获取指定用户信息并放在视图上

package cn.edu.ssmdemo.controller;

import cn.edu.ssmdemo.model.User;
import cn.edu.ssmdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/user")
    public String user(Model model){
        User user = userService.selectByPrimaryKey(20230903);
        model.addAttribute("user",user);
        System.out.println("用户信息:" + user);
        return "user";
    }
}

4.在 webapp/WEB-INF/views 目录下创建对应的视图 user.jsp

<%--
  Created by IntelliJ IDEA.
  User: dell
  Date: 2023/9/3
  Time: 18:18
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<body>
    用户信息:${user}
</body>
</html>

最后,启动 JRebel ,测试结果
在这里插入图片描述

结果如图:
在这里插入图片描述

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

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

相关文章

桌面型物联网智能机器人设计(预告)

相关资料 桌面级群控机器人CoCube探索-2022--CSDN博客 视频&#xff1a; 能&#xff01;有&#xff01;多&#xff01;酷&#xff01;CoCube桌面级群控机器人 让我看看谁在SJTU里划水… 简要介绍 设计一个桌面型物联网智能机器人&#xff0c;以ESP32芯片为核心&#xff0c;配…

Spring Security 6 学习-1

什么是 Spring Security Spring Security文档 Spring Security中文文档 Spring Security 是 Spring 家族中的安全型开发框架&#xff0c;主要解决三大方面问题&#xff1a;认证&#xff08;你是谁&#xff09;、授权&#xff08;你能干什么&#xff09;、常见攻击保护&#xff…

vue项目中使用Element多个Form表单同时验证

一、项目需求 在项目中一个页面中需要实现多个Form表单&#xff0c;并在页面提交时需要对多个Form表单进行校验&#xff0c;多个表单都校验成功时才能提交。 二、实现效果 三、多个表单验证 注意项&#xff1a;多个form表单&#xff0c;每个表单上都设置单独的model和ref&am…

GPT4+Python近红外光谱数据分析及机器学习与深度学习建模

详情点击链接&#xff1a;GPT4Python近红外光谱数据分析及机器学习与深度学习建模 第一&#xff1a;GPT4入门基础 1、ChatGPT概述&#xff08;GPT-1、GPT-2、GPT-3、GPT-3.5、GPT-4模型的演变&#xff09; 2、ChatGPT对话初体验&#xff08;注册与充值、购买方法&#xff09…

写Shell以交互方式变更Ubuntu的主机名

以下是一个简单的 Bash 脚本&#xff0c;用于以交互方式更改 Ubuntu 20 系统的主机名&#xff1a; 1#!/bin/bash 2 3# 提示用户输入新的主机名 4read -p "请输入新的系统名称&#xff08;主机名&#xff09;: " new_hostname 5 6# 检查是否输入了新的主机名 7if [ -…

Parallels Desktop 18 for Mac(pd虚拟机) 激活版

Parallels Desktop 18是一款功能强大的虚拟机软件&#xff0c;可以在Mac操作系统上同时运行多种操作系统&#xff0c;包括Windows、Linux、Android等。该软件提供了多种高级功能&#xff0c;如支持DirectX 11游戏、3D图形和OpenGL应用程序&#xff0c;以及运行Windows和Mac应用…

OpenCV书签 #余弦相似度的原理与相似图片/相似文件搜索实验

1. 介绍 余弦相似度&#xff08;Cosine Similarity&#xff09;&#xff0c;又称为余弦相似性&#xff0c;是通过计算两个向量的夹角余弦值来评估他们的相似度。余弦相似度仅仅与向量的指向方向相关&#xff0c;与向量的长度无关&#xff0c;它将向量根据坐标值绘制到向量空间…

网络协议与攻击模拟_07UDP协议

一、简单概念 1、UDP协议简介 UDP&#xff08;用户数据报&#xff09;协议&#xff0c;是传输层的协议。不需要建立连接&#xff0c;直接发送数据&#xff0c;不会重新排序&#xff0c;不需要确认。 2、UDP报文字段 源端口目的端口UDP长度UDP校验和 3、常见的UDP端口号 5…

Springboot+vue的医院后台管理系统(有报告),Javaee项目,springboot vue前后端分离项目

演示视频&#xff1a; Springbootvue的医院后台管理系统&#xff08;有报告&#xff09;&#xff0c;Javaee项目&#xff0c;springboot vue前后端分离项目 项目介绍&#xff1a; 本文设计了一个基于Springbootvue的前后端分离的医院后台管理系统&#xff0c;采用M&#xff08…

Git的管理操作

目录 前言 认识工作区、暂存区、版本库 小结&#xff1a; 使用场景--1&#xff1a; git log&#xff1a; 查看.git文件&#xff1a; 使用场景--2&#xff1a; git status&#xff1a; git diff&#xff1a; 进行提交&#xff1a; 总结&#xff1a; 版本回退 退…

Overleaf(LaTeX文档在线编写平台)使用学习记录

一、LaTeX简概[1] LaTeX&#xff0c;是一种基于TEX的排版系统&#xff0c;是一种可以处理排版和渲染的标记语言。由美国计算机科学家莱斯利兰伯特在20世纪80年代初期开发&#xff0c;利用这种格式系统的处理&#xff0c;即使用户没有排版和程序设计的知识也可以充分发挥由TEX所…

服务器的异步通信——RabbitMQ

目录 一、同步通信 VS 异步通信 二、MQ——消息队列 RabbitMQ RabbitMQ安装 RabbitMQ的整体架构 常见消息模型 基本消息队列&#xff08;BasicQueue&#xff09; 工作消息队列&#xff08;WorkQueue&#xff09; 发布、订阅&#xff08;Publish、Subscribe&#xff0…

【CANoe使用大全】——工程新建

文章目录 1、硬件连接2、通道配置2.1通道协议选择2.2映射通道配置2.3.波特率采样点配置 1、硬件连接 前提条件&#xff1a;软件、驱动均已经安装完成 硬件通过UBS接入电脑&#xff0c;Status状态灯为黄色闪烁状态说明硬件设备与电脑连接正常 2、通道配置 2.1通道协议选择 …

架构师的36项修炼-01大型架构演进之路

本课时的主题是大型互联网系统架构的演进之路&#xff0c;主要包含三部分内容。 第一部分是大型互联网系统的特点&#xff0c;分析大型互联网有哪些特点和挑战&#xff0c;它们是现在一些技术和架构方案产生的原因。 第二部分是系统处理能力提升的两种途径&#xff0c;提供了…

Elasticsearch:使用 Gemini、Langchain 和 Elasticsearch 进行问答

本教程演示如何使用 Gemini API创建 embeddings 并将其存储在 Elasticsearch 中。 我们将学习如何将 Gemini 连接到 Elasticsearch 中存储的私有数据&#xff0c;并使用 Langchian 构建问答功能。 准备 Elasticsearch 及 Kibana 如果你还没有安装好自己的 Elasticsearch 及 Ki…

C#winform上位机开发学习笔记6-串口助手的断帧功能添加

1.功能描述 按照设定时间对接收数据进行断帧(换行) 应用于需要接收完整数据包的场景&#xff0c;例如下位机发送一包数据为1秒&#xff0c;每100ms发送一组数据 大部分用于接收十六进制数据时 2.代码部分 步骤1&#xff1a;添加计时器&#xff0c;设置默认时间为500ms 步骤…

【多商户开源-BSD- Fecmall 电商平台】

关于Fecmall Fecmall 关于&#xff0c;Fecmall介绍 Fecbbc开源BSD多商户系统&#xff0c;真正开源&#xff0c;商用免费授权的多商户系统 Fecmall系统简介&#xff1a; 全称为Fancy ECommerce Shop&#xff0c; 着重于电商架构的研发优化&#xff0c;全新定义商城的架构体系&…

react18介绍

改进已有属性&#xff0c;如自动批量处理【setState】、改进Suspense、组件返回undefined不再报错等 支持Concurrent模式&#xff0c;带来新的API&#xff0c;如useTransition、useDeferredValue等 如何升级React 18 npm install reactlatest react-domlatestnpm install ty…

学会使用ubuntu——ubuntu22.04使用WebCatlog

Ubuntu22.04使用WebCatlog WebCatlog是适用于Gnu / Linux&#xff0c;Windows或Mac OS X系统的桌面程序。 引擎基于铬&#xff0c;它用于在我们的桌面上处理Web服务。简单点就是把网页单独一个窗口出来显示&#xff0c;当一个app用。本文就是利用WebCatlog安装后的notion编写的…

技术驱动宠物健康:宠物在线问诊系统的高效搭建手册

在数字化时代&#xff0c;技术正在催生出许多创新的医疗服务&#xff0c;而宠物在线问诊系统便是其中一项引领潮流的创举。本文将为你提供一份高效搭建宠物在线问诊系统的手册&#xff0c;通过技术代码示例&#xff0c;让你轻松打造一套技术驱动的宠物健康管理系统。 1. 架构…