René's URL Explorer Experiment


Title: 添加多租户共享模式以优化资源使用 by Copilot · Pull Request #3840 · binarywang/WxJava · GitHub

Open Graph Title: 添加多租户共享模式以优化资源使用 by Copilot · Pull Request #3840 · binarywang/WxJava

X Title: 添加多租户共享模式以优化资源使用 by Copilot · Pull Request #3840 · binarywang/WxJava

Description: Spring Boot Starter 的多租户实现为每个租户创建独立的 WxService 实例和 HTTP 客户端,而基础 SDK 类已支持通过 configMap 管理多配置。这导致 100 个租户需要 100 个 HTTP 客户端(~500MB)。 解决方案 新增可配置的多租户模式,默认保持现有行为: ISOLATED(默认):每租户独立实例,线程安全,适合异步场景 SHARED(新增):单实例 + configMap,共享 HTTP 客户端,节省 ~90% 内存 实现 配置属性: wx: ma: # 或 mp apps: tenant1: app-id: wx123 app-secret: secret1 tenant2: app-id: wx456 app-secret: secret2 config-storage: multi-tenant-mode: shared # isolated | shared 代码使用(两种模式 API 完全一致): @Autowired private WxMaMultiServices services; WxMaService wxService = services.getWxMaService(tenantId); wxService.getUserService().getUserInfo(...); 变更范围 新增类: WxMaMultiServicesSharedImpl / WxMpMultiServicesSharedImpl 新增配置: MultiTenantMode 枚举(ISOLATED, SHARED) multi-tenant-mode 配置项 重构: AbstractWxMaConfiguration / AbstractWxMpConfiguration 支持模式选择 使用 TreeMap 保证默认租户选择的确定性 支持模块 ✅ 小程序(MiniApp) ✅ 公众号(MP) 注意事项 共享模式依赖 ThreadLocal 切换配置,异步场景需预先获取配置信息: // ❌ 错误 CompletableFuture.runAsync(() -> wxService.getAccessToken()); // ✅ 正确 String token = wxService.getAccessToken(); CompletableFuture.runAsync(() -> process(token)); 向后兼容 完全兼容。未配置 multi-tenant-mode 时使用 ISOLATED 模式,行为与旧版本一致。 Original prompt This section details on the original issue you should resolve 关于源码的请教 基础Wx实现类中已经有configMap了,可以用configMap来存储不同的小程序配置。不同的配置,都是复用同一个http客户端。为什么在各个spring-boot-starter中又单独创建类来存储不同的配置?从spring的配置来看,http客户端只有一个,不同小程序配置可以实现多租户,所以似乎没必要单独再建新类存放?重复创建,增加了http客户端的成本?直接使用Wx实现类中已经有configMap不是更好吗?是有什么我没有考虑到的bug吗? ps:因为我的项目要引入该开源项目,但提供的标准starter不能完全满足我们的要求。我在改造的时候看到有这个写法,所以有疑惑,希望有大佬看见了,可以解答下。我更倾向直接服用Wx实现类中已经有configMap Comments on the Issue (you are @copilot in this section) Custom agent used: 全部用中文 需要用中文,包括PR标题和分析总结过程 Fixes #3835 💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Open Graph Description: Spring Boot Starter 的多租户实现为每个租户创建独立的 WxService 实例和 HTTP 客户端,而基础 SDK 类已支持通过 configMap 管理多配置。这导致 100 个租户需要 100 个 HTTP 客户端(~500MB)。 解决方案 新增可配置的多租户模式,默认保持现有行为: ISOLATED(默认):每租户独立实例,线程安全,适合异步场景 SHARED(...

X Description: Spring Boot Starter 的多租户实现为每个租户创建独立的 WxService 实例和 HTTP 客户端,而基础 SDK 类已支持通过 configMap 管理多配置。这导致 100 个租户需要 100 个 HTTP 客户端(~500MB)。 解决方案 新增可配置的多租户模式,默认保持现有行为: ISOLATED(默认):每租户独立实例,线程安全,适合异步场景 SHARED(...

Opengraph URL: https://github.com/binarywang/WxJava/pull/3840

X: @github

direct link

Domain: patch-diff.githubusercontent.com

route-pattern/:user_id/:repository/pull/:id/files(.:format)
route-controllerpull_requests
route-actionfiles
fetch-noncev2:28d100fe-312a-18b1-ff12-8382abe01462
current-catalog-service-hashae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b
request-id802C:2AB245:8CE7E7F:B9B9946:696DF036
html-safe-nonce57fd2b98723bb451c1551301a10fe23740d20f4568fb9511cdd737be54fb2d48
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MDJDOjJBQjI0NTo4Q0U3RTdGOkI5Qjk5NDY6Njk2REYwMzYiLCJ2aXNpdG9yX2lkIjoiNjYxODM0ODc0NTgwNjE4MDQwNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmac34e9f49dc7f95bcece328ec823c2c3eddc391783d574364bf1d8d1df5e6a25a0
hovercard-subject-tagpull_request:3158547134
github-keyboard-shortcutsrepository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///pull_requests/show/files
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/binarywang/WxJava/pull/3840/files
twitter:imagehttps://avatars.githubusercontent.com/in/1143301?s=400&v=4
twitter:cardsummary_large_image
og:imagehttps://avatars.githubusercontent.com/in/1143301?s=400&v=4
og:image:altSpring Boot Starter 的多租户实现为每个租户创建独立的 WxService 实例和 HTTP 客户端,而基础 SDK 类已支持通过 configMap 管理多配置。这导致 100 个租户需要 100 个 HTTP 客户端(~500MB)。 解决方案 新增可配置的多租户模式,默认保持现有行为: ISOLATED(默认):每租户独立实例,线程安全,适合异步场景 SHARED(...
og:site_nameGitHub
og:typeobject
hostnamegithub.com
expected-hostnamegithub.com
None4922b452d03cd8dbce479d866a11bc25b59ef6ee2da23aa9b0ddefa6bd4d0064
turbo-cache-controlno-preview
diff-viewunified
go-importgithub.com/binarywang/WxJava git https://github.com/binarywang/WxJava.git
octolytics-dimension-user_id1343140
octolytics-dimension-user_loginbinarywang
octolytics-dimension-repository_id49122742
octolytics-dimension-repository_nwobinarywang/WxJava
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49122742
octolytics-dimension-repository_network_root_nwobinarywang/WxJava
turbo-body-classeslogged-out env-production page-responsive full-width
disable-turbotrue
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release7e5ae23c70136152637ceee8d6faceb35596ec46
ui-targetfull
theme-color#1e2327
color-schemelight dark

Links:

Skip to contenthttps://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files#start-of-content
https://patch-diff.githubusercontent.com/
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fbinarywang%2FWxJava%2Fpull%2F3840%2Ffiles
GitHub CopilotWrite better code with AIhttps://github.com/features/copilot
GitHub SparkBuild and deploy intelligent appshttps://github.com/features/spark
GitHub ModelsManage and compare promptshttps://github.com/features/models
MCP RegistryNewIntegrate external toolshttps://github.com/mcp
ActionsAutomate any workflowhttps://github.com/features/actions
CodespacesInstant dev environmentshttps://github.com/features/codespaces
IssuesPlan and track workhttps://github.com/features/issues
Code ReviewManage code changeshttps://github.com/features/code-review
GitHub Advanced SecurityFind and fix vulnerabilitieshttps://github.com/security/advanced-security
Code securitySecure your code as you buildhttps://github.com/security/advanced-security/code-security
Secret protectionStop leaks before they starthttps://github.com/security/advanced-security/secret-protection
Why GitHubhttps://github.com/why-github
Documentationhttps://docs.github.com
Bloghttps://github.blog
Changeloghttps://github.blog/changelog
Marketplacehttps://github.com/marketplace
View all featureshttps://github.com/features
Enterpriseshttps://github.com/enterprise
Small and medium teamshttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
App Modernizationhttps://github.com/solutions/use-case/app-modernization
DevSecOpshttps://github.com/solutions/use-case/devsecops
DevOpshttps://github.com/solutions/use-case/devops
CI/CDhttps://github.com/solutions/use-case/ci-cd
View all use caseshttps://github.com/solutions/use-case
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
View all industrieshttps://github.com/solutions/industry
View all solutionshttps://github.com/solutions
AIhttps://github.com/resources/articles?topic=ai
Software Developmenthttps://github.com/resources/articles?topic=software-development
DevOpshttps://github.com/resources/articles?topic=devops
Securityhttps://github.com/resources/articles?topic=security
View all topicshttps://github.com/resources/articles
Customer storieshttps://github.com/customer-stories
Events & webinarshttps://github.com/resources/events
Ebooks & reportshttps://github.com/resources/whitepapers
Business insightshttps://github.com/solutions/executive-insights
GitHub Skillshttps://skills.github.com
Documentationhttps://docs.github.com
Customer supporthttps://support.github.com
Community forumhttps://github.com/orgs/community/discussions
Trust centerhttps://github.com/trust-center
Partnershttps://github.com/partners
GitHub SponsorsFund open source developershttps://github.com/sponsors
Security Labhttps://securitylab.github.com
Maintainer Communityhttps://maintainers.github.com
Acceleratorhttps://github.com/accelerator
Archive Programhttps://archiveprogram.github.com
Topicshttps://github.com/topics
Trendinghttps://github.com/trending
Collectionshttps://github.com/collections
Enterprise platformAI-powered developer platformhttps://github.com/enterprise
GitHub Advanced SecurityEnterprise-grade security featureshttps://github.com/security/advanced-security
Copilot for BusinessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/premium-support
Pricinghttps://github.com/pricing
Search syntax tipshttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
documentationhttps://docs.github.com/search-github/github-code-search/understanding-github-code-search-syntax
Sign in https://patch-diff.githubusercontent.com/login?return_to=https%3A%2F%2Fgithub.com%2Fbinarywang%2FWxJava%2Fpull%2F3840%2Ffiles
Sign up https://patch-diff.githubusercontent.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fpull_requests%2Fshow%2Ffiles&source=header-repo&source_repo=binarywang%2FWxJava
Reloadhttps://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files
Reloadhttps://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files
Reloadhttps://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files
binarywang https://patch-diff.githubusercontent.com/binarywang
WxJavahttps://patch-diff.githubusercontent.com/binarywang/WxJava
Please reload this pagehttps://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files
Notifications https://patch-diff.githubusercontent.com/login?return_to=%2Fbinarywang%2FWxJava
Fork 9k https://patch-diff.githubusercontent.com/login?return_to=%2Fbinarywang%2FWxJava
Star 32.5k https://patch-diff.githubusercontent.com/login?return_to=%2Fbinarywang%2FWxJava
Code https://patch-diff.githubusercontent.com/binarywang/WxJava
Issues 13 https://patch-diff.githubusercontent.com/binarywang/WxJava/issues
Pull requests 7 https://patch-diff.githubusercontent.com/binarywang/WxJava/pulls
Discussions https://patch-diff.githubusercontent.com/binarywang/WxJava/discussions
Actions https://patch-diff.githubusercontent.com/binarywang/WxJava/actions
Wiki https://patch-diff.githubusercontent.com/binarywang/WxJava/wiki
Security Uh oh! There was an error while loading. Please reload this page. https://patch-diff.githubusercontent.com/binarywang/WxJava/security
Please reload this pagehttps://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files
Insights https://patch-diff.githubusercontent.com/binarywang/WxJava/pulse
Code https://patch-diff.githubusercontent.com/binarywang/WxJava
Issues https://patch-diff.githubusercontent.com/binarywang/WxJava/issues
Pull requests https://patch-diff.githubusercontent.com/binarywang/WxJava/pulls
Discussions https://patch-diff.githubusercontent.com/binarywang/WxJava/discussions
Actions https://patch-diff.githubusercontent.com/binarywang/WxJava/actions
Wiki https://patch-diff.githubusercontent.com/binarywang/WxJava/wiki
Security https://patch-diff.githubusercontent.com/binarywang/WxJava/security
Insights https://patch-diff.githubusercontent.com/binarywang/WxJava/pulse
Sign up for GitHub https://patch-diff.githubusercontent.com/signup?return_to=%2Fbinarywang%2FWxJava%2Fissues%2Fnew%2Fchoose
terms of servicehttps://docs.github.com/terms
privacy statementhttps://docs.github.com/privacy
Sign inhttps://patch-diff.githubusercontent.com/login?return_to=%2Fbinarywang%2FWxJava%2Fissues%2Fnew%2Fchoose
binarywanghttps://patch-diff.githubusercontent.com/binarywang
develophttps://patch-diff.githubusercontent.com/binarywang/WxJava/tree/develop
copilot/fix-spring-boot-starter-issuehttps://patch-diff.githubusercontent.com/binarywang/WxJava/tree/copilot/fix-spring-boot-starter-issue
Conversation 15 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840
Commits 9 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/commits
Checks 0 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/checks
Files changed 8 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files
添加多租户共享模式以优化资源使用 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files#top
Show all changes 9 commits https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files
bc07e25 Initial plan Copilot Jan 9, 2026 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/commits/bc07e2526c521d77396ff877d1404984d10995e9
dc84bc5 添加共享式多租户实现支持 Copilot Jan 9, 2026 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/commits/dc84bc5a5e5996d56d4557531355ef72ee003a61
92ae2a2 添加多租户模式使用文档 Copilot Jan 9, 2026 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/commits/92ae2a259bd7763430fee80305b07ce210366676
d9ce230 为公众号模块添加共享式多租户支持 Copilot Jan 9, 2026 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/commits/d9ce230401c393aa37706bb6ce43d841aa04b692
664a5e4 添加多租户模式改进总体说明文档 Copilot Jan 9, 2026 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/commits/664a5e47726123f435a4209a0ff6308da46f6cd2
c1f950c 修复代码审查问题:避免通配符导入,使用TreeMap保证租户顺序一致性 Copilot Jan 9, 2026 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/commits/c1f950c8a21206083484272bbefc2c1d9385ad68
a0a18b9 Apply suggestion from @Copilot binarywang Jan 10, 2026 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/commits/a0a18b9522766c158f11066e81e6dc82a6536d46
19ee495 修复所有 Review Comments 已修复完成 binarywang Jan 10, 2026 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/commits/19ee495fb1493058daa2cca6dcda4103291820a8
29e6ce9 fix javadoc binarywang Jan 12, 2026 https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/commits/29e6ce947bebd3949924739543f94a875c45141e
Clear filters https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files
Please reload this pagehttps://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files
Please reload this pagehttps://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files
MULTI_TENANT_MODE_IMPROVEMENT.md https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files#diff-c7964f203a455c3a7020d7a0a15ac4861301eac5bc58d9296953e7deeafead80
MULTI_TENANT_MODE.md https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files#diff-f9c8ad9f8228a1bdddb70ae103efba728d9abe80bce6bac828e0ad68fb754289
AbstractWxMaConfiguration.java https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files#diff-26cc4625670986ad2e01e4d73526ff8ab6f3e45b630e41abddc1109a90a485c6
WxMaMultiProperties.java https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files#diff-581e670424e98fab54135b651d328f70063d39f14e51727f97b963ebaf4fd043
WxMaMultiServicesSharedImpl.java https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files#diff-0af346c11ba1ef3c8e6d2fb878d48dad16c30d75601fba2c8367c03383af8826
AbstractWxMpConfiguration.java https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files#diff-2cdd48f9e9aeff85cf8e2e0fe0aab3a8c6452d1f7bbece8fe82111e3396c7ad7
WxMpMultiProperties.java https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files#diff-89d68b90560c77b66f0367cf0d830df39a900d30b181b527ef4b1186f9bacd5f
WxMpMultiServicesSharedImpl.java https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files#diff-eae01622845dcc81b908fda0dd755f1f57a22a079541a39c72ae2b6eb6d377de
spring-boot-starters/MULTI_TENANT_MODE_IMPROVEMENT.mdhttps://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files#diff-c7964f203a455c3a7020d7a0a15ac4861301eac5bc58d9296953e7deeafead80
View file https://patch-diff.githubusercontent.com/binarywang/WxJava/blob/29e6ce947bebd3949924739543f94a875c45141e/spring-boot-starters/MULTI_TENANT_MODE_IMPROVEMENT.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/{{ revealButtonHref }}
...ng-boot-starters/wx-java-miniapp-multi-spring-boot-starter/MULTI_TENANT_MODE.mdhttps://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files#diff-f9c8ad9f8228a1bdddb70ae103efba728d9abe80bce6bac828e0ad68fb754289
View file https://patch-diff.githubusercontent.com/binarywang/WxJava/blob/29e6ce947bebd3949924739543f94a875c45141e/spring-boot-starters/wx-java-miniapp-multi-spring-boot-starter/MULTI_TENANT_MODE.md
Open in desktop https://desktop.github.com
https://github.co/hiddenchars
https://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/{{ revealButtonHref }}
Please reload this pagehttps://patch-diff.githubusercontent.com/binarywang/WxJava/pull/3840/files
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.