[SSM]Spring面向切面编程AOP

news2024/9/27 23:29:45

目录

十五、面向切面编程AOP

15.1AOP介绍

15.2AOP的七大术语

15.3切点表达式

15.4使用Spring的AOP

15.4.1准备工作

15.4.2基于AspectJ的AOP注解式开发

15.4.3基于XML配置方式的AOP(了解)

15.5AOP的实际案例:事务处理

15.6AOP的实际案例:安全日志


十五、面向切面编程AOP

  • IoC使软件组件松耦合。AOP让你能够捕捉系统中经常使用的功能,把它转化为组件。

  • AOP(Aspect Oriented Programming):面向切面编程。

  • AOP是对OOP(面向对象编程)的补充延伸。

  • AOP底层使用的就是动态代理来实现的。

  • Spring的AOP使用的动态代理是:JDK动态代理+CGLIB动态代理技术。Spring在这两种动态代理中灵活切换,如果是代理接口,会默认使用JDK动态代理,如果要代理某个类,这个类没有实现接口,就会切换使用CGLIB。当然,你也可以强制通过一些配置让Spring只使用CGLIB。

15.1AOP介绍

  • 一般一个系统当中都会有一些系统服务,例如:日志、事务管理、安全等。这些系统服务被称为:交叉业务。

  • 这些交叉业务几乎是通用的,不管你是做银行账户转账,还是删除用户数据。日期、事务管理、安全,这些都是需要的。

  • 如果在每一个业务处理过程中,都掺杂这些交叉业务代码进去的话,存在两方面问题:

    • 第一:交叉业务代码在多个业务流程中反复出现,显然这个交叉业务代码没有得到复用,并且修改这些交叉业务代码的话,需要修改多处。

    • 第二:程序员无法专注核心业务代码的编写,在编写核心业务代码的同时还需要处理这些交叉业务。

  • 使用AOP可以很轻松的解决这些问题。

  • 用一句话总结AOP:将与核心业务无关的代码独立的抽取出来,形成一个独立的组件,然年以横向交叉的方式应用到业务流程当中的过程被称为AOP。

  • AOP的优点:

    • 代码复用性增强。

    • 代码易维护。

    • 使开发者更关注业务逻辑。

15.2AOP的七大术语

  • 连接点 Joinpoint

    • 在程序的整个执行流程中,可以织入切面的位置。方法的执行前后,异常抛出之后的位置。

  • 切点 Pointcut

    • 在程序执行流程中,真正注入切面的方法。(一个切点对应多个连接点)

  • 通知 Advice

    • 通知又叫做增强,就是具体你要织入的代码。

    • 通知包括:

      • 前置通知

      • 后置通知

      • 环绕通知

      • 异常通知

      • 最终通知

  • 切面 Aspect

    • 切点+通知就是切面

  • 织入 Weaving

    • 把通知应用到目标对象上的过程。

  • 代理对象 Proxy

    • 一个目标对象被织入通知后产生的新对象。

  • 目标对象 Target

    • 被织入通知的对象。

 

 

15.3切点表达式

  • 切点表达式用来定义通知(Advice)往哪些方法上切入。

  • 切入点表达式语法格式:

execution([访问控制权限修饰符] 返回值类型 [全限定类名] 方法名(形式参数列表) [异常])
  • 访问控制权限修饰符:

    • 可选项

    • 没写就是4个权限都包括

    • 写public就表示只包括公开的方法

  • 返回值类型:

    • 必填项

    • *表示返回值类型任意

  • 全限定类名:

    • 可选项

    • 两个点".."代表当前包以及子包下的所有类

    • 省略时表示所有的类

  • 方法名:

    • 必填项

    • *表示所有方法

    • set*表示所有的set方法

  • 形式参数列表:

    • 必填项

    • ()表示没有参数的方法

    • (..)参数类型和个数随意的方法

    • (*)只有一个参数的方法

    • (*,String)第一个参数类型随意,第二个参数是String的

  • 异常:

    • 可选项

    • 省略时表示任意异常类型

execution(public * com.hhb.service.*.delete*(..))
  • service包下所有类中以delete开始的所有方法

execution(* com.hhb.mall..*(..))
  • mall包下所有的类的所有的方法

execution(* *(..))
  • 所有类的所有方法

15.4使用Spring的AOP

  • Spring对AOP的实现包括以下3种方式:

    • 第一种方式:Spring框架结合AspectJ框架实现的AOP,基于注解开发。

    • 第二种方式:Spring框架结合AspectJ框架实现的AOP,基于XML方式。

    • 第三种方式:Spring框架自己实现的AOP,基于XML配置方式。

  • 实际开发中,都是Spring+AspectJ来实现AOP,所有重点学习第一种和第二种方式。

  • 什么时AspectJ?

    • Eclipse组织的一个支持AOP的框架,AspectJ框架是独立于Spring框架之外的一个框架,Spring框架用了AspectJ。

15.4.1准备工作

  • 使用Spring+AspectJ的AOP需要引入的依赖如下:

<dependencies>
        <!--spring-context依赖-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>6.0.3</version>
        </dependency>
        <!--spring-aspects依赖-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>6.0.3</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.13.2</version>
            <scope>test</scope>
        </dependency>
    </dependencies>
  • Spring配置文件中添加context命名空间和aop命名空间

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

15.4.2基于AspectJ的AOP注解式开发

第一步:定义目标类以及目标方法

package com.hhb.service;
​
import org.springframework.stereotype.Service;
​
@Service("userService")
public class UserService {//目标类
​
    public void login() {//目标方法
        System.out.println("系统正在进行身份认证...");
    }
​
    public void logout() {
        System.out.println("退出系统...");
    }
}
package com.hhb.service;
​
import org.springframework.stereotype.Service;
​
@Service("orderService")
public class OrderService {//目标类
    //目标方法
    public void generate(){
        System.out.println("系统正在生成订单");
    }
}

第二步:定义切面类

package com.hhb.service;
​
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
​
@Component("logAspect")
@Aspect //切面类是需要使用@Aspect注解进行标注的
public class LogAspect {//切面
    //切面=通知+切点
    //通知就是增强,就是具体的要编写的增强代码
    //@Before注解标注的放法就是一个前置通知
    @Before("execution(* com.hhb.service..*(..))")
    public void 增强() {
        System.out.println("通知,增强代码");
    }
}

第三步:在spring配置文件中添加组件扫描和自动代理

<?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:aop="http://www.springframework.org/schema/aop"
       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
                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
​
    <!--组件扫描-->
    <context:component-scan base-package="com.hhb.service"/>
​
    <!--开启aspectj的自动代理-->
    <!--spring容器在扫描类的时候,查看该类上是否有@Aspect注解,如果有,则给这个类生成代理对象-->
    <!--
        proxy-target-class="true"  表示强制使用CGLIB动态代理
        proxy-target-class="false" 这是默认值,表示接口使用JDK动态代理,反之使用CGLIB动态代理。
    -->
    <aop:aspectj-autoproxy/>
</beans>

第四步:测试

@Test
public void testBefore() {
    ApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring.xml");
    UserService userService = applicationContext.getBean("userService", UserService.class);
    userService.login();
    userService.logout();
​
    OrderService orderService = applicationContext.getBean("orderService", OrderService.class);
    orderService.generate();
}

 

通知类型

  • 通知类型包括:

    • 前置通知:@Before目标方法执行之前的通知

    • 后置通知:@AfterReturning目标方法执行之后的通知

    • 环绕通知:@Around目标方法之前添加通知,目标方法之后添加通知

    • 异常通知:@AfterThrowing发生异常之后执行的通知

    • 最终通知:@After放在finally语句块中的通知

  • 测试

 
package com.hhb.service;
​
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;
​
@Component("logAspect")
@Aspect
public class LogAspect {//切面
​
    @Before("execution(* com.hhb.service..*(..))")
    public void beforeAdvice() {
        System.out.println("前置通知");
    }
​
    @AfterReturning("execution(* com.hhb.service..*(..))")
    public void afterReturningAdvice() {
        System.out.println("后置通知");
    }
​
    @Around("execution(* com.hhb.service..*(..))")
    public void aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("前环绕");
        //执行目标
        joinPoint.proceed();
        System.out.println("后环绕");
    }
​
    @AfterThrowing("execution(* com.hhb.service..*(..))")
    public void testAfterThrowing() {
        System.out.println("异常通知");
    }
    
    //最终通知(finally语句中执行的通知)
    @After("execution(* com.hhb.service..*(..))")
    public void testAfter() {
        System.out.println("最终通知");
    }
}

 

  • 当发生异常时

 

 

切面的先后执行顺序

  • 在业务中有多个切面的话,可以使用@Order注解来标识切面类,为@Order注解的value指定一个整数型的数字,数字越小,优先级越高。

package com.hhb.service;
​
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
​
@Component("logAspect")
@Aspect 
@Order(0)
public class LogAspect {//切面
​
    @Before("execution(* com.hhb.service..*(..))")
    public void beforeAdvice() {
        System.out.println("前置通知");
    }
​
    @AfterReturning("execution(* com.hhb.service..*(..))")
    public void afterReturningAdvice() {
        System.out.println("后置通知");
    }
​
    @Around("execution(* com.hhb.service..*(..))")
    public void aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("前环绕");
        joinPoint.proceed();
        System.out.println("后环绕");
    }
​
    @AfterThrowing("execution(* com.hhb.service..*(..))")
    public void testAfterThrowing() {
        System.out.println("异常通知");
    }
​
    @After("execution(* com.hhb.service..*(..))")
    public void testAfter() {
        System.out.println("最终通知");
    }
}
package com.hhb.service;
​
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
​
@Aspect
@Component
@Order(1)//数字越小,优先级越高
public class SecurityAspect {
    @Before("execution(* com.hhb.service..*(..))")
    public void beforeAdvice() {
        System.out.println("前置通知,安全");
    }
}

 

通用切点

  • 之前的切点表达式缺点:

    • 切点表达式重复写了多次,没有得到复用。

    • 如果要修改切点表达式,需要修改多处,难维护。

  • 改进:将切点表达式单独的定义出来,在需要的位置引入即可。如下:

package com.hhb.service;
​
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
​
@Component("logAspect")
@Aspect //切面类是需要使用@Aspect注解进行标注的
@Order(0)
public class LogAspect {//切面
​
    //定义通用的切点表达式
    @Pointcut("execution(* com.hhb.service..*(..))")
    public void 通用切点() {
        //这个方法只是一个标记,方法名随意,方法体中也不需要写任何代码
    }
    
    /* @Before("execution(* com.hhb.service..*(..))")*/
    @Before("通用切点()")
    public void beforeAdvice() {
        System.out.println("前置通知");
    }
​
    @AfterReturning("通用切点()")
    public void afterReturningAdvice() {
        System.out.println("后置通知");
    }
​
    @Around("通用切点()")
    public void aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
        System.out.println("前环绕");
        joinPoint.proceed();
        System.out.println("后环绕");
    }
​
    @AfterThrowing("通用切点()")
    public void testAfterThrowing() {
        System.out.println("异常通知");
    }
​
    @After("通用切点()")
    public void testAfter() {
        System.out.println("最终通知");
    }
}

 

package com.hhb.service;
​
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
​
@Aspect
@Component
@Order(1)//数字越小,优先级越高
public class SecurityAspect {
    @Before("com.hhb.service.LogAspect.通用切点()")
    public void beforeAdvice() {
        System.out.println("前置通知,安全");
    }
}

连接点

@Before("通用切点()")
public void beforeAdvice(JoinPoint joinPoint) {
    System.out.println("前置通知");
    System.out.println("目标方法的方法名:"+joinPoint.getSignature().getName());
}
  • JoinPoint在Spring容器调用这个方法的时候传过来,我们可以直接使用。

  • joinPoint.getSignature(); 获取目标方法的签名。

  • 通过方法的签名可以获取到一个方法的具体信息。

全注解式开发AOP

  • 就是编写一个类,在这个类上面使用大量注解来代替spring的配置文件,如下Spring6Config:

package com.hhb.service;
​
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
​
@Configuration//代替spring.xml文件
@ComponentScan({"com.hhb.service"})//组件扫描
@EnableAspectJAutoProxy(proxyTargetClass = true)//启用aspectj的自动代理机制
public class Spring6Config {
}
  • 测试程序发生变化

@Test
public void testNoXML(){
    ApplicationContext applicationContext=new AnnotationConfigApplicationContext(Spring6Config.class);
    OrderService orderService = applicationContext.getBean("orderService", OrderService.class);
    orderService.generate();
}

15.4.3基于XML配置方式的AOP(了解)

第一步:编写目标类

package com.hhb.service;
​
public class UserService {//目标对象
​
    //目标方法
    public void logout() {
        System.out.println("系统正在退出...");
    }
}

第二步:编写切面类,并编写通知

package com.hhb.service;
​
import org.aspectj.lang.ProceedingJoinPoint;
​
public class TimerAspect {
    //通知
    public void aroundAdvice(ProceedingJoinPoint joinPoint) throws Throwable {
        //前环绕
        long begin = System.currentTimeMillis();
        //目标
        joinPoint.proceed();
        //后环绕
        long end = System.currentTimeMillis();
        System.out.println("耗时" + (end - begin) + "毫秒");
    }
}

第三步:编写的spring配置文件

<?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:aop="http://www.springframework.org/schema/aop"
       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
                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
​
    <!--纳入spring ioc-->
    <bean id="userService" class="com.hhb.service.UserService"/>
    <bean id="timerAspect" class="com.hhb.service.TimerAspect"/>
​
    <!--aop的配置-->
    <aop:config>
        <!--切点表达式-->
        <aop:pointcut id="mypointcut" expression="execution(* com.hhb.service..*())"/>
        <!--切面=通知+切点-->
        <aop:aspect ref="timerAspect">
            <aop:around method="aroundAdvice" pointcut-ref="mypointcut"/>
        </aop:aspect>
    </aop:config>
</beans>

第四步:测试

15.5AOP的实际案例:事务处理

  • 项目中的事务控制是在所难免的,在一个业务流程当中,可能需要多条DML语句共同完成,为了保证数据的安全,这多条DML语句要么同时成功,要么同时失败,这就需要添加事务控制的代码。

  • 控制事务的代码就是和业务逻辑没有关系的”交叉业务“。可以使用AOP思想解决,可以把以上控制事务的代码作为环绕通知,切入到目标类的方法当中。

业务类

package com.hhb.service;
​
import org.springframework.stereotype.Service;
​
@Service
public class AccountService {
    public void transfer() {
        System.out.println("正在转账");
    }
​
    public void withdraw() {
        System.out.println("正在取款");
        String s=null;
        s.toString();
    }
}
package com.hhb.service;
​
import org.springframework.stereotype.Service;
​
@Service
public class OrderService {
    public void generate() {
        System.out.println("正在生成订单");
    }
​
    public void cancel() {
        System.out.println("订单已取消");
    }
}

事务切面类

package com.hhb.service;
​
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
​
@Component
@Aspect
public class TransactionAspect {
    //编程式事务解决方案
    @Around("execution(* com.hhb.service..*(..))")
    public void aroundAdvice(ProceedingJoinPoint joinPoint) {
        try {
            //前环绕
            System.out.println("开启事务");
            //执行目标
            joinPoint.proceed();
            //后环绕
            System.out.println("提交事务");
        } catch (Throwable e) {
            System.out.println("回滚事务");
        }
    }
}

spring配置文件

<?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:aop="http://www.springframework.org/schema/aop"
       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
                           http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
​
    <!--组件扫描-->
    <context:component-scan base-package="com.hhb.service"/>
    <!--启动自动代理-->
    <aop:aspectj-autoproxy/>
</beans>

测试

 

15.6AOP的实际案例:安全日志

  • 项目开发结束,已经上线了并且运行正常。客户提出新的需求:凡是在系统中进行修改、删除、新增操作的,都要把这个人记录下拉,因为这几个操作是属于危险行为。

业务类

package com.hhb.biz;
​
import org.springframework.stereotype.Service;
​
@Service
public class UserService {
​
    public void saveUser(){
        System.out.println("新增用户信息");
    }
​
    public void deleteUser(){
        System.out.println("删除用户信息");
    }
​
    public void modifyUser(){
        System.out.println("修改用户信息");
    }
​
    public void getUser(){
        System.out.println("获取用户信息");
    }
}
package com.hhb.biz;
​
import org.springframework.stereotype.Service;
​
@Service
public class VipService {
​
    public void saveVip(){
        System.out.println("新增会员信息");
    }
​
    public void deleteVip(){
        System.out.println("删除会员信息");
    }
​
    public void modifyVip(){
        System.out.println("修改会员信息");
    }
​
    public void getVip(){
        System.out.println("获取会员信息");
    }
}

切面类

package com.hhb.biz;
​
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;
​
import java.text.SimpleDateFormat;
import java.util.Date;
​
@Component
@Aspect
public class SecurityLogAspect {
    @Pointcut("execution(* com.hhb.biz..save*(..))")
    public void savePointcut() {
    }
​
    @Pointcut("execution(* com.hhb.biz..delete*(..))")
    public void deletePointcut() {
    }
​
    @Pointcut("execution(* com.hhb.biz..modify*(..))")
    public void modifyPointcut() {
    }
​
    @Before("savePointcut()||deletePointcut()||modifyPointcut()")
    public void beforeAdvice(JoinPoint joinPoint) {
        //系统时间
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss SSS");
        String nowTime = sdf.format(new Date());
        //输出日志信息
        System.out.println(nowTime + " XXX : " + joinPoint.getSignature().getDeclaringTypeName() + "." + joinPoint.getSignature().getName());
    }
}

测试

 

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

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

相关文章

flask用DBUtils实现数据库连接池

flask用DBUtils实现数据库连接池 在 Flask 中&#xff0c;DBUtils 是一种实现数据库连接池的方案。DBUtils 提供了持久性&#xff08;persistent&#xff09;和透明的&#xff08;transient&#xff09;两种连接池类型。 首先你需要安装 DBUtils 和你需要的数据库驱动。例如&…

关于c++中虚函数和虚函数表的创建时机问题

以这段代码为例。 #include <iostream>using namespace std;class Parent { public:Parent(){}virtual void func1() {};virtual void func2() {}; };class Child :public Parent { public:Child():n(0),Parent(){cout << "Child()" << endl;}vir…

【机器学习】西瓜书学习心得及课后习题参考答案—第4章决策树

这一章学起来较为简单&#xff0c;也比较好理解。 4.1基本流程——介绍了决策树的一个基本的流程。叶结点对应于决策结果&#xff0c;其他每个结点则对应于一个属性测试&#xff1b;每个结点包含的样本集合根据属性测试的结果被划分到子结点中&#xff1b;根结点包含样本全集&a…

js中的遍历方法比较:map、for...in、for...of、reduce和forEach的特点与适用场景

&#x1f60a;博主&#xff1a;小猫娃来啦 &#x1f60a;文章核心&#xff1a;JavaScript中的遍历方法比较&#xff1a;map、for…in、for…of和forEach的特点与适用场景 文章目录 map 方法概述用法返回值特点 for...in 循环概述用法注意事项 for...of 循环概述用法可迭代对象…

苍穹外卖day09——历史订单模块(用户端)+订单管理模块(管理端)

查询历史订单——需求分析与设计 产品原型 业务规则 分页查询历史订单 可以根据订单状态查询 展示订单数据时&#xff0c;需要展示的数据包括&#xff1a;下单时间、订单状态、订单金额、订单明细&#xff08;商品名称、图片&#xff09; 接口设计 查询历史订单——代码开…

抖音seo短视频账号矩阵系统技术开发简述

说明&#xff1a;本开发文档适用于抖音seo源码开发&#xff0c;抖音矩阵系统开发&#xff0c;短视频seo源码开发&#xff0c;短视频矩阵系统源码开发 一、 抖音seo短视频矩阵系统开发包括 抖音seo短视频账号矩阵系统的技术开发主要包括以下几个方面&#xff1a; 1.前端界面设…

线程初见——对速度的追求

文章目录 线程进程线程区别线程之间资源线程库介绍 线程 同一个程序的所有线程共享一份全局内存区域 特例&#xff1a;只包含一个线程的进程 查看线程号&#xff1a;ps -Lf 号 和进程类似&#xff0c;完成并发任务的执行 进程线程区别 区别进程线程信息交换内存未共享&#xf…

cad丢失mfc140u.dll怎么办?找不到mfc140u.dll的解决方法

第一&#xff1a;mfc140u.dll有什么用途&#xff1f; mfc140u.dll是Windows操作系统中的一个动态链接库文件&#xff0c;它是Microsoft Foundation Class (MFC)库的一部分。MFC是 C中的一个框架&#xff0c;用于构建Windows应用程序的用户界面和功能。mfc140u.dll包含了MFC库中…

CAN15765和1939协议

1. 15765协议介绍 简单的来说&#xff0c;15765协议指的是 基于CAN2.0A/B 协议 &#xff08;也可以叫做ISO11898协议 -链路层&#xff09; 硬件接口的 应用层 通讯协议&#xff0c; 它用于实现通用的车辆诊断服务。 ISO11898协议参考下图。 参考搜索到的“CAN总线协议讲解…

【MySQL】索引特性

​&#x1f320; 作者&#xff1a;阿亮joy. &#x1f386;专栏&#xff1a;《零基础入门MySQL》 &#x1f387; 座右铭&#xff1a;每个优秀的人都有一段沉默的时光&#xff0c;那段时光是付出了很多努力却得不到结果的日子&#xff0c;我们把它叫做扎根 目录 &#x1f449;没…

蓝图节点编辑器

打印字符串 第02章 蓝图结构 03 -注释和重新路由_哔哩哔哩_bilibili 第02章 蓝图结构 04 - 变量_哔哩哔哩_bilibili 第03章 蓝图简易门 01 - 箱子碰撞_哔哩哔哩_bilibili 第03章 蓝图简易门 02 - 静态Mesh和箭头_哔哩哔哩_bilibili 第03章 蓝图简易门 03 - 设置相对旋转节点_哔…

流数据湖平台Apache Paimon(三)Flink进阶使用

文章目录 2.9 进阶使用2.9.1 写入性能2.9.2 读取性能2.9.3 多Writer并发写入2.9.4 表管理2.9.5 缩放Bucket 2.10 文件操作理解2.10.1 插入数据2.10.2 删除数据2.10.3 Compaction2.10.4 修改表2.10.5 过期快照2.10.6 Flink 流式写入 2.9 进阶使用 2.9.1 写入性能 Paimon的写入…

c++ 类的特殊成员函数:拷贝构造函数(四)

1. 简介 拷贝构造是一种特殊的构造函数&#xff0c;用于创建一个对象&#xff0c;该对象是从同一类中的另一个对象复制而来的。拷贝构造函数通常采用引用参数来接收要复制的对象&#xff0c;并使用该对象的副本来创建一个新对象。 2. 结构 class MyClass { public:MyClass(c…

一种新的基于区域的在线活动轮廓模型研究(Matlab代码实现)

&#x1f4a5;&#x1f4a5;&#x1f49e;&#x1f49e;欢迎来到本博客❤️❤️&#x1f4a5;&#x1f4a5; &#x1f3c6;博主优势&#xff1a;&#x1f31e;&#x1f31e;&#x1f31e;博客内容尽量做到思维缜密&#xff0c;逻辑清晰&#xff0c;为了方便读者。 ⛳️座右铭&a…

SpringBoot热部署的开启与关闭

1、 开启热部署 &#xff08;1&#xff09;导入依赖 <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId> </dependency>&#xff08;2&#xff09;设置 此时就搞定了。。。 2、…

TCP网络通信编程之网络上传文件

【图片】 【思路解析】 【客户端代码】 import java.io.*; import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException;/*** ProjectName: Study* FileName: TCPFileUploadClient* author:HWJ* Data: 2023/7/29 18:44*/ public class TCPFil…

解决在云服务器开放端口号以后telnet还是无法连接的问题

这里用阿里云服务器举例&#xff0c;在安全组开放了对应的TCP端口以后。使用windows的cmd下的telnet命令&#xff0c;还是无法正常连接。 telnet IP地址 端口号解决方法1&#xff1a; 在轻量服务器控制台的防火墙规则中添加放行端口。 阿里云-管理防火墙 如图&#xff0c;开放…

Windows 11 下 OpenFace 2.2.0 的安装

写在前面 最近需要做关于面部的东西&#xff0c;所以需要使用到OpenFace这个工具&#xff0c;本文仅用来记录本人安装过程以供后续复现&#xff0c;如果可以帮助到读者也是非常荣幸。 安装过程 不编译直接使用 这种方法可以直接从官方下载下来编译好的exe以及gui进行使用&a…

1000Wqps生产级IM,怎么架构?

前言 在40岁老架构师 尼恩的读者社区(50)中&#xff0c;很多小伙伴拿高薪&#xff0c;完成架构的升级&#xff0c;进入架构师赛道&#xff0c;打开薪酬天花板。 然后&#xff0c;在架构师的面试过程中&#xff0c;常常会遇到IM架构的问题&#xff1a; 如果要你从0到1做IM架构…

python与深度学习(十):CNN和cifar10二

目录 1. 说明2. cifar10的CNN模型测试2.1 导入相关库2.2 加载数据和模型2.3 设置保存图片的路径2.4 加载图片2.5 图片预处理2.6 对图片进行预测2.7 显示图片 3. 完整代码和显示结果4. 多张图片进行测试的完整代码以及结果 1. 说明 本篇文章是对上篇文章训练的模型进行测试。首…