EasyMock gets more power with PowerMock.

There are a lot of mocking libraries for Java, out of which EasyMock is my favorite. It has been serving well for me until I had to unit test legacy code which did not completely adhere to IOC (inversion of control) principles and had a lot of static method calls and direct creation of service/helper objects instead of using dependency injection. Unfortunately EasyMock could not handle mocking of static methods and objects which were created directly in the class or method being tested along with some other limitations such handling final classes.
This forced me to use other mocking libraries until I encountered PowerMock. It provides all the ammunition (and more) in dealing with these issues and has nice integration with EasyMock.
Here I’ll show you how to use EasyMock with PowerMock in order to handle common mocking test cases which were not possible with EasyMock before.


Set Up.
First to use PowerMock with easymock you need PowerMock libraries.
Here is maven dependency list:

<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>1.4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-test-easymock-junit4</artifactId>
<version>1.4.10</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.easymock</groupId>
<artifactId>easymock</artifactId>
<version>3.0</version>
<scope>test</scope>
</dependency>

Code to be tested.

public class SampleService {

private SampleServiceHelper sampleServiceHelper = new SampleServiceHelper();

public String method1(){
return "method1:" +
SampleUtils.staticMethod();
//we will need to mock this static method call
}

public String method2(){
return "method2:" +
sampleServiceHelper.helperMethod();
//we will need to mock this method call on global variable that is created during class initialization
}

public String method3(){
SampleServiceHelper2 sampleServiceHelper2 = new SampleServiceHelper2();
return "method3:" +
sampleServiceHelper2.helperMethod();
//we will need to mock this method call on variable that is created within this method
}

public String method4(){
return "method4:" +
privateMethod("someParam");
//we will partially mock this private method call
}

public String method5(){
return "method5:" +
SampleUtils.staticMethod() +
privateMethod("someParam") +
sampleServiceHelper.helperMethod();
//we will mock all three calls in the last test
}

protected String privateMethod(String param){
return "privateMethod-" + param;
}
}
view rawSampleService.javaThis Gist brought to you by GitHub.
public final class SampleServiceHelper {

public String helperMethod(){
return "helperMethod";
}
}
view rawSampleServiceHelper.javaThis Gist brought to you by GitHub.
public class SampleServiceHelper2 {

public String helperMethod(){
return "helperMethod";
}
}
view rawSampleServiceHelper2.javaThis Gist brought to you by GitHub.
public class SampleUtils {

private SampleUtils(){
}

public static String staticMethod(){
return "staticMethod";
}
}

view rawSampleUtils.javaThis Gist brought to you by GitHub.
The Unit Tests.
I am creating 5 different tests in order to gradually show you how to test different scenarios with last one combining all into one test as an example of how everything can work together.

import org.easymock.EasyMock;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;

import org.powermock.api.easymock.PowerMock;
import org.powermock.modules.junit4.PowerMockRunner;
import org.powermock.core.classloader.annotations.PrepareForTest;

//This is required for PowerMock to work.
@RunWith(PowerMockRunner.class)
//The following class are included in @PrepareForTest because:
//- SampleUtils.class. So that PowerMock will handle static method calls.
// Notice that even though SampleUtils has private constructor PowerMock can
// still handle mocking it.
//
//- SampleServiceHelper. Because its declared as final class and EasyMock wont
// be able to mock it.
//
//- SampleService.class. So that PowerMock could intercept creation
// of SampleServiceHelper class. And could do partial mocking of
// "privateMethod" private method.
@PrepareForTest( {SampleUtils.class, SampleServiceHelper.class,
SampleService.class} )
public class SampleServiceTest {

@Test
public void testMethod1() throws Exception{
//This will mock the SampleUtils static method calls.
PowerMock.mockStatic(SampleUtils.class);

//Just do plain "new" of SampleService here since we are not calling
//any private method inthis test method that need to be partially mocked.
SampleService sampleService = new SampleService();

//Here we are telling what should happens when SampleUtils.staticMethod()
//gets called. We can use EasyMock to do the expectation even though PowerMock
//is mocking the static method call.
EasyMock.expect( SampleUtils.staticMethod() ).andReturn("mockedStaticMethod");

//We need to have PowerMock replay SampleUtils.just like its done
//with SampleServiceHelper.class
//We cannot use EasyMock in this case since it does not handle Class objects.
PowerMock.replay(SampleUtils.class);

//------ Do actually call the method to be tested and do necessary assertions.
String result = sampleService.method1();

assertEquals( "method1:" + "mockedStaticMethod", result );

//------ Do necessary verification to make sure that all methods we expected
//to be called are called

//Verification of Class mocks need to go through PowerMock, just like in replay.
PowerMock.verify(SampleUtils.class);
}

@Test
public void testMethod2() throws Exception{
//Here are going to tell PowerMock to replace all calls to new SampleServiceHelper
//in SampleService with sampleServiceHelperMock. Notice that even though SampleServiceHelper is final
//we now can mock it using EasyMock because is included in @PrepareForTest declaration.
//Powermock example says to use PowerMock.mock but this works as well.
SampleServiceHelper sampleServiceHelperMock =
EasyMock.createMock(SampleServiceHelper.class);
//Here we tell PowerMock to intercept all creations of SampleServiceHelper
PowerMock.expectNew(SampleServiceHelper.class).andReturn(sampleServiceHelperMock);
//PowerMock requires us to call this. Otherwise it will fail to intercept call to
//"new" SampleServiceHelper. Cant use EasyMock here since it does not support
//mocking Class objects.
PowerMock.replay(SampleServiceHelper.class);

//We need to create SampleService after the above call because
//SampleServiceHelper is created during SampleService initialization.
//"method3" will show you that you dont need to do this when object to be mocked
//is created inside method that is tested.
//
//Just do plain "new" of SampleService here since we are not calling any method in
//this test method that need to be partially mocked.
SampleService sampleService = new SampleService();

//We can use EasyMock to replay plain mocks.
EasyMock.expect( sampleServiceHelperMock.helperMethod() )
.andReturn("mockedHelperMethod");

//Again since sampleServiceHelper is mocked with EasyMock, we can replay it with
//EasyMock.
EasyMock.replay(sampleServiceHelperMock);

//------ Do actually call the method to be tested and do necessary assertions.
String result = sampleService.method2();

assertEquals( "method2:" + "mockedHelperMethod", result );

//------ Do necessary verification to make sure that all methods we expected
//to be called are called

//Verification of Class mocks need to go through PowerMock, just like in replay.
PowerMock.verify(SampleServiceHelper.class);

EasyMock.verify(sampleServiceHelperMock);
}

@Test
public void testMethod3() throws Exception{
//Here are going to tell PowerMock to replace call to new SampleServiceHelper2
//in SampleService with sampleServiceHelper2Mock.
SampleServiceHelper2 sampleServiceHelper2Mock =
EasyMock.createMock(SampleServiceHelper2.class);
//Here we tell PowerMock to intercept all creations of SampleServiceHelper2
PowerMock.expectNew(SampleServiceHelper2.class).andReturn(sampleServiceHelper2Mock);

//Here we dont need to create SampleService before calling
//PowerMock.replay(SampleServiceHelper2.class), since SampleServiceHelper2
//is created inside method3.
//
//Just do plain "new" of SampleService here since we are not calling any method in
//this test method that need to be partially mocked.
SampleService sampleService = new SampleService();

//Called after creation of SampleService.
PowerMock.replay(SampleServiceHelper2.class);

//We can use EasyMock to replay plain mocks.
EasyMock.expect( sampleServiceHelper2Mock.helperMethod() )
.andReturn("mockedHelperMethod");

//Again since sampleServiceHelper2Mock is mocked with EasyMock and we can replay it with
//EasyMock. Notice that even though "sampleService" is partially mocked by PowerMock
//we still can replay it using EasyMock.
EasyMock.replay(sampleServiceHelper2Mock);

//------ Do actually call the method to be tested and do necessary assertions.
String result = sampleService.method3();

assertEquals( "method3:" + "mockedHelperMethod", result );

//------ Do necessary verification to make sure that all methods we expected
//to be called are called

//Verification of Class mocks need to go through PowerMock, just like in replay.
PowerMock.verify(SampleServiceHelper2.class);

EasyMock.verify(sampleServiceHelper2Mock);
}

@Test
public void testMethod4() throws Exception{
//Since we want to mock "privateMethod" we need to
//partially mock SampleService with PowerMock.
//
//Also notice that we are not calling createPartialMock with constructor
//arguments (like in testMethod5) since method4 does not use SampleServiceHelper.
SampleService sampleService =
PowerMock.createPartialMock(SampleService.class,
"privateMethod", new Class[]{String.class} );

PowerMock.expectPrivate(sampleService, "privateMethod",
"someParam").andReturn("mockedPrivateMethod");

//Notice that even though "sampleService" is partially mocked by PowerMock
//we still can replay it using EasyMock.
EasyMock.replay(sampleService);

//------ Do actually call the method to be tested and do necessary assertions.
String result = sampleService.method4();

assertEquals( "method4:" + "mockedPrivateMethod", result );

//------ Do necessary verification to make sure that all methods we expected
//to be called are called

EasyMock.verify(sampleService);
}

@Test
public void testMethod5() throws Exception{
//This will mock the SampleUtils static method calls.
PowerMock.mockStatic(SampleUtils.class);

//Here are going to tell PowerMock to replace calls to new SampleServiceHelper
//in SampleService with sampleServiceHelperMock.
SampleServiceHelper sampleServiceHelperMock =
EasyMock.createMock(SampleServiceHelper.class);
//Here we tell PowerMock to intercept all creations of SampleServiceHelper
PowerMock.expectNew(SampleServiceHelper.class).andReturn(sampleServiceHelperMock);
//PowerMock requires us to call this. Otherwise it will fail to intercept call to
//"new" SampleServiceHelper. Cant use EasyMock here since it does not support
//mocking Class objects.
PowerMock.replay(SampleServiceHelper.class);

//We need to create SampleService after the above call because
//SampleServiceHelper is create during SampleService initialization
//"method3" will show you that you dont need to do this when object to be mocked
//is created inside method that is tested.
//
//Since we want to mock "privateMethod" (which is private) we need to
//partially mock SampleService with PowerMock.
//
//Also notice that we are calling createPartialMock with constructor
//arguments since plain createPartialMock wont "by default" invoke constructor and
//do class initialization which will prevent us from initializing sampleServiceHelper
//variable.
SampleService sampleService =
PowerMock.createPartialMock(SampleService.class,
"privateMethod", new Class[]{String.class}, new Object[]{}, new Class[]{} );

PowerMock.expectPrivate(sampleService, "privateMethod",
"someParam").andReturn("mockedPrivateMethod");

//Here we are telling what should happens when SampleUtils.staticMethod()
//gets called. We can use EasyMock to do the expectation even though PowerMock
//is mocking the static method call.
EasyMock.expect( SampleUtils.staticMethod() ).andReturn("mockedStaticMethod");

//We need to have PowerMock replay SampleUtils.just like its done
//with SampleServiceHelper.class
PowerMock.replay(SampleUtils.class);

//We can use EasyMock to replay plain mocks.
EasyMock.expect( sampleServiceHelperMock.helperMethod() )
.andReturn("mockedHelperMethod");

//Again since sampleServiceHelper is mocked with EasyMock, we can replay it with
//EasyMock. Notice that even though "sampleService" is partially mocked by PowerMock
//we still can replay it using EasyMock.
EasyMock.replay(sampleServiceHelperMock, sampleService);

//------ Do actually call the method to be tested and do necessary assertions.
String result = sampleService.method5();

assertEquals( "method5:" + "mockedStaticMethod" +
"mockedPrivateMethod" + "mockedHelperMethod", result );

//------ Do necessary verification to make sure that all methods we expected
//to be called are called

//Verification of Class mocks need to go through PowerMock, just like in replay.
PowerMock.verify(SampleUtils.class, SampleServiceHelper.class);

EasyMock.verify(sampleServiceHelperMock, sampleService);
}
}

view rawSampleServiceTest.javaThis Gist brought to you by GitHub.
Update: Just encountered limitation with PowerMock (and probably with any other Mocking frameworks) that it cannot mock “java.lang.reflect.Method”. The workaround is to just declare inner class that has method you need to mock.
Realtek RTD1319D芯片解析:H.266与AV1双解码的机顶盒SoC 视频编解码技术是数字媒体传输的核心,H.266/VVC作为新一代标准,相比H.265提升50%压缩效率,显著降低带宽需求。其实现原理依赖于专用硬件解码器和并行处理架构,在超高清视频传输领域具有重要价值。Realtek RTD1319D作为首款商用H.266处理器,采用异构计算设计,集成四核ARM CPU和独立视频处理单元,同时支持AV1解码,兼顾市场兼容性。该SoC特别适合4K机顶盒、数字标牌等应用场景,其HDMI 2.1a接口和DVB解调器为超高清内容传输提供完整解决方案。开发时需注意散热设计和内存配置优 阅读详情

相关推荐

point transformer v3结构

分割结构: embedding->enc->dec embedding->enc0->enc1->enc2->enc3->enc4->dec3->dec2->dec1->dec0 embedding ->block0->block1 ->dow->block0->block1 ->dow->block0->block1 ->dow->block0->block1-&gt

weixin_45625419的博客 590

Java EE 进阶:11. SpringBoot 统一功能处理(第二弹):DispatcherServlet 源码分析+适配器模式

Java EE 进阶:11. SpringBoot 统一功能处理(第二弹):DispatcherServlet 源码分析+适配器模式

要努力去发光,而不是被照亮~ 347

.NET+Vue企业级RBAC权限平台:开箱即用的生产就绪方案

RBAC(基于角色的访问控制)是企业系统安全治理的基础模型,其核心在于将用户、角色与权限解耦,通过动态能力组合实现细粒度管控。在真实工程中,RBAC需突破静态角色限制,支持时间维度授权、前后端双重鉴权、行级数据范围控制等关键能力。本文聚焦于一套已落地金融、政务、制造等多行业的生产级实现——基于.NET Minimal API与Vue 3的前后端分离架构,提供菜单/按钮/接口/数据四层权限控制,内置滑动过期JWT、Redis权限缓存、动态路由加载与权限指令等开箱即用能力,显著降低权限配置与审计成本。

weixin_33326218的博客 286

javascript 基础 es6:4、Symbol,Symbol创建对象属性,Symbol内置属性,迭代器,迭代器自定义遍历对象

本文介绍了ES6中Symbol的创建与特性,包括Symbol()和Symbol.for()的区别,Symbol作为唯一属性名解决命名冲突;通过[Symbol()]方式安全添加对象属性;利用内置Symbol属性(如Symbol.isConcatSpreadable)自定义行为;最后讲解迭代器机制,通过Symbol.iterator实现自定义遍历逻辑,支持for...of循环。

狮子座的男孩 209

【Ubuntu】Ubuntu常见优化设置

本笔记基于 Ubuntu20.04; 因工作需要,需要长期使用Ubuntu系统,在这里记录下Ubuntu系统常见优化设置;

我还可以 2116

基于Python的虚拟货币社区情绪分析与市场价格预测爬虫实现

本文探讨了如何利用Python爬虫技术获取虚拟货币社区数据,并通过情感分析预测市场价格走势。我们将使用最新的异步爬虫框架、自然语言处理技术和机器学习模型,构建一个完整的社区情绪分析系统。本文提供了详细的代码实现和理论解释,适合作为毕业设计参考。关键词:Python爬虫、虚拟货币、情感分析、价格预测、异步爬虫、机器学习爬虫框架aiohttp和httpx用于异步HTTP请求HTML解析和parsel数据存储MongoDB和Pandas用于数据处理自然语言处理库和VADER情感分析工具机器学习和。

2201_76125261的博客 529

二分查找:在有序数组中查找最接近 target 的元素索引

本文分析了二分查找中寻找最接近目标值元素的实现问题,指出原代码存在溢出风险、冗余计算及平局处理不清晰等缺陷。提出更优解法:通过二分收敛至相邻两位置,循环后仅比较两个候选值,使用long避免整型溢出,逻辑更简洁、安全。该方法在负数、重复值、平局等场景下表现更稳健,时间复杂度保持$\mathcal{O}(\log N)$,且代码可读性与维护性显著提升。

qq_38030465的博客 356

Modbus测试工具ModbusPoll与Modbus Slave使用方法 小白实操记录

Modbus 下面介绍modbus标准协议从站、主站仿真工具;可用于指令下发,数据采集等;是学习、现场运维的好工具。 1 介绍 Modbus Poll :Modbus主机仿真器,用于测试和调试Modbus从设备。该软件支持ModbusRTU、ASCII、TCP/IP。用来帮助开发人员测试Modbus从设备,或者其它Modbus协议的测试和仿真。它支持多文档接口,即,可以同时监视多个从设备/数据域。每个窗口简单地设定从设备ID,功能,地址,大小和轮询间隔。你可以从任意一个窗口读写寄存器和线圈。如果你想改

码灵的博客 1万+

Spring Boot + LangChain4j 实战多模态:上传截图、流式输出、单 Jar 部署全流程

本文介绍一个纯Java实现的截图转文字Demo,基于JDK21 + Spring Boot 3.5.16 + LangChain4j 1.20.2 + Vue3,支持灵活传参、流式输出与Markdown自动折叠。无需Python或GPU,仅通过云端多模态接口即可完成图像理解与文本生成。重点解决接口变更、流式调用、图片压缩、并发限流等实战坑点,强调Java在多模态场景下的可行性与工程优势。源码已开源,一键运行即可体验。

sch7979的博客 689

【DRAM存储器三十】DDR4介绍-DDR4 SDRAM的主要技术特性之bank group,为什么要搞个group出来?

详述DDR4 bank group的作用

highman110的博客 2157

【PyTorch项目实战】之ResNet系列:resnet18、resnet34、resnet50、resnet101、resnet152

ResNet (Residual Network) :是一种深度卷积神经网络(CNN)架构,其核心思想是引入残差学习(Residual Learning)机制,通过跳跃连接(skip connections)来解决深层网络训练中的退化问题。

📷 图像处理践行者 | 传统算法 · 深度学习 · 多模态 | 分享实战经验与技术洞见,探索从像素到智能的无限可能。 6393

《阿里巴巴 Java 开发手册》的 MySQL 核心规范

既然你平时经常自己练习表结构设计,那这份提炼自《阿里巴巴 Java 开发手册》的 MySQL 核心规范,绝对是你日常建表和写 SQL 时的“避坑宝典”。我帮你把最核心的【强制】级别规范,按和。

qq_26889291的博客 365

工业级实战:C#实现欧姆龙PLC FINS-TCP通信(协议解析+完整源码+避坑指南)

// FINS主命令码+子命令码枚举(工业级常用指令)ReadData = 0x0101, // 读取数据WriteData = 0x0102, // 写入数据ReadPlcStatus = 0x0601, // 读取PLC状态ResetPlc = 0x0605 // 复位PLC(慎用)/// 欧姆龙PLC数据区枚举(工业常用)CIO = 0x30, // CIO区(核心数据区)WR = 0x31, // 工作区HR = 0x32, // 保持区。

这里只有干货:从 Modbus 通信到 MES 对接,从 YOLO 训练到工控机部署,带你搞定工业软件开发全流程。 666

为什么 HashMap 使用时要指定容量?

如果在多线程环境下扩容,可能出现数据覆盖、链表结构异常等问题(JDK 8 已修复了 JDK 7 中著名的死循环问题,但并发写入依然不安全)。提前指定容量可以减少扩容次数,降低风险窗口。假设要插入 10000 个元素,从默认 16 开始,会经历 16 → 32 → 64 → …每次扩容都要迁移已有元素,累计的迁移成本相当可观。在元素量较大时,指定容量通常能减少多次扩容,耗时更低。在大容量场景下,这会瞬间占用双倍内存,给 GC 带来压力。得到 256,阈值 192,足够容纳 100 个元素且不扩容。

2601_96930216的博客 292

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

笔面试复盘总结

看jdtoC高并发项目会拷打锁、并发容器、缓存中间件纯业务类会问Spring和Java基础,JVM等大厂额外会问语言以外的计算机基础知识。

写代码的小阿帆的博客 238

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

mybatis-plus初次使用

由于mybatis-plus框架spring框架没有集成进来,所以需要另外导入依赖 相关依赖可以在MyBatis-Plus🚀为简化开发而生官网中导入 MybatisPlus提供了⼀个基础的BaseMapper 接口,已经实现了单表的CRUD,我们自定义的 Mapper只需要继承这个BaseMapper,就无需自己实现单表CRUD了 在Mapper中没有定义任何接口,测试继承了< BaseMapper > 后的UserInfoMapper 是否可以操作数据库在上面的程序中,MyBatis-Plus是如何知

2302_81707171的博客 248

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

Java方向-AI核心技能栈

software_0215的专栏 156

七、MyBatis 源码剖析:核心流程拆解(初始化 + SQL 执行)

本文聚焦 MyBatis 源码核心流程:SqlSessionFactory 初始化与 SQL 执行。通过“入口定位+源码片段+断点技巧”,拆解配置解析(XMLConfigBuilder 生成 Configuration)和动态代理执行 SQL 的完整链路,强调抓主线、按流程、多调试的学习方法,帮助开发者快速掌握 80% 面试高频考点,小白也能轻松入门源码分析。

2403_88625492的博客 344

‌Tomcat 下载安装配置完整教程

2026最新版Tomcat 11.0.29下载安装配置完整教程,手把手教你在Windows系统上完成Tomcat安装、环境变量配置与启动测试,附常见问题排查方案,新手也能快速搭建Java Web服务器环境。立即查看!

Helix250的博客 669

MCP 面试高频考点:把内部 REST API 封装成可审计 Tools,OpenTelemetry 与最小权限怎么落地

面试场景 某公司有一批内部 REST API(订单查询、退款发起、客户资料读取等),希望把它们封装成 MCP Tools,让内部的 AI 应用通过 MCP Client 调用。安全团队的要求是: 每次调用都能审计到“谁、何时、调了哪个 To。

a3258264204的博客 201

Java多线程实验实训报告

原子操作是指不可被中断的一个或一系列操作,要么全部执行完成,要么完全不执行,执行过程中不会被其他线程打断。像i++这类操作在底层包含读取、计算、写回多个步骤,并非原子操作,多线程并发时容易出错。使用关键字修饰方法或代码块,通过对象锁保证同一时刻只有一个线程进入临界区;使用等显式锁,手动加锁和解锁,控制更灵活;使用volatile关键字保证变量的可见性(注意它不能保证复合操作的原子性);使用原子类,如,通过 CAS 机制实现无锁的原子操作。本实验主要采用。

cats_eat_fish_的博客 329

Boot4.2升后WebFlux上传限额怎么设

Boot 4.2 起 WebFlux 上传默认每 part 1MB、最多 50 个 part;超限会失败,可上调或设 -1。part 数超限与磁盘超限不是同一状态码,勿写成一律 413。

Amax3747的博客 381

Spring Cloud 微服务分布式深度实践:从注册发现到分布式事务

本文基于JDK 21、Spring Boot 3.2.12与Spring Cloud 2023.0.6,实测验证微服务七大核心组件:服务注册发现(Nacos AP模式)、配置中心、API网关、服务调用与负载均衡、熔断限流(Sentinel/R4j)、分布式事务(Seata)。通过真实环境部署与命令行输出,深入剖析CAP定理在注册中心设计中的应用,强调“分区时选A而非放弃P”,并结合PACELC理论说明正常场景下延迟与一致性的权衡,为微服务架构选型提供可复现的实践依据。

一只懂代码不懂人情世故的源码爱好猿 255

同城O2O宠物服务平台开发架构实践:基于状态机模式与Spring StateMachine的到家洗护订单履约引擎设计

本文针对同城O2O宠物到家洗护平台订单履约复杂性,提出基于SpringStateMachine状态机框架、策略模式与Redis状态快照的混合架构。通过声明式配置状态流转,实现逻辑解耦与高可维护性;利用Redis存储状态快照,支持状态回溯与审计;结合异常补偿机制,保障支付超时、技师拒单等场景下的业务闭环。该设计显著提升系统鲁棒性与可扩展性,为复杂服务类SaaS平台提供可靠技术范式。

fhw13005668659的博客 146

KMP-CMP 鸿蒙冷启动与包体积归因实战:源码级移植 Koin 4.1.1,把依赖图初始化与双 ABI so 从首屏关键路径上拆下来

本文基于KMP-CMP架构,针对鸿蒙跨平台应用冷启动慢、包体积大、首屏白屏等问题,提出“启动与包体预算台”实验方案。通过移植Koin 4.1.1至鸿蒙(坐标com.ohos.koin:koin-core:4.1.1-ohos.1),实现对依赖注入初始化耗时、libkn.so体积及首屏白屏的统一量化测量。实测显示:释放包体积减少34.1%,双ABI libkn.so减小36.2%,首屏依赖解析耗时降低50%以上。所有数据来自同一模拟器环境,支持可复现验证,为跨平台启动优化提供可信基准。

白天写代码,晚上追AI大模型,偶尔搞点八卦 开源动态|技术干货|实习机会|生态活动 我负责分享,你负责变强 143

采购管理系统(Spring Boot 3 + Vue 3)

一套可直接运行的采购管理系统,包含供应商、商品、采购订单审批、入库、库存流水、用户权限、个人中心与数据看板。支持用户头像与商品图片上传(本地存储、缩略图展示、点击大图预览),个人中心可修改资料和密码。系统自带 8 张真实商品图片,位于。

深耕开发,专注编程实战。分享源码解析、项目搭建、问题排查笔记,沉淀技术,持续更新。 256
上一篇: 小心“微博”指向危险链接的短网址
下一篇: Log4j之logger.isInfoEnabled()和logger.isDebugEnabled
iteye_5726
博客等级 码龄8年 1粉丝 9原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值