Skip to content

fix(wx-java-mp): 对齐 MiniApp 的 Redis host 默认值 - #4148

Merged
binarywang merged 8 commits into
binarywang:developfrom
miemieYaho:codex/wxmp-redis-host-default
Nov 14, 2026
Merged

binarywang merged 8 commits into
binarywang:developfrom
miemieYaho:codex/wxmp-redis-host-default

Conversation

@miemieYaho

Copy link
Copy Markdown
Contributor

变更

将公众号 Spring Boot Starter 的 Redis host 默认值改为 null,与 MiniApp 对齐。应用已经提供 RedissonClient 时,只设置 wx.mp.config-storage.type=redisson 即可复用该客户端。

- private String host = "127.0.0.1";
+ private String host;

MiniApp 的 RedisProperties.host 没有初始值。省略 host 时,MiniApp 按类型查找应用已有的 RedissonClient。MP 原有代码也有相同的回退分支,但默认的 127.0.0.1 会让查找误入专用客户端分支。此时 wxMpRedissonClient 因缺少 host 配置而没有注册,导致 WxMpService 初始化失败。

显式配置有效 host 时,MP 仍由 Spring 创建并管理专用客户端。MP 的 Jedis 模式也使用同一个 host 属性,省略 host 时会复用应用提供的 JedisPool。

验证

mvn -pl spring-boot-starters/wx-java-mp-spring-boot-starter -am -DskipTests compile 编译通过。

替代 #4147。

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-12T09:40:44.734154Z c00082c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c00082c48c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

* 主机地址.
*/
private String host = "127.0.0.1";
private String host;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 说明省略 Redis host 时的客户端复用契约

在 wx.mp.config-storage.type=jedis/redisson 场景,此行把“省略 host”变成复用容器中客户端的配置契约,但该模块的 README.md 仍只给出显式的 host=127.0.0.1,当前字段说明也没有说明省略值需要现有客户端;发布后用户无法从随包文档得知新用法,并会在容器中没有相应 bean 时直到启动阶段才看到失败。请同步补充 host 的省略语义及前置条件。

AGENTS.md reference: AGENTS.md:L89-L89

Useful? React with 👍 / 👎.

* 主机地址.
*/
private String host = "127.0.0.1";
private String host;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 为 Redis 客户端回退增加回归测试

该修改通过把 host 默认值设为 null 来切换 WxMpInRedissonConfigStorageConfiguration 和 WxMpInJedisConfigStorageConfiguration 的 bean 查找分支,但受影响模块当前没有测试覆盖“省略 host 且容器已有客户端”的启动场景;以后默认值或分支改动时,原来的 NoSuchBeanDefinitionException 可以直接回归而 CI 无法发现。请添加最小 Spring 上下文回归测试,至少验证未配置 host 时会复用已有 RedissonClient,并覆盖同一字段影响的 Jedis 分支。

AGENTS.md reference: AGENTS.md:L64-L64

Useful? React with 👍 / 👎.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are recorded for the Redis host-default change and its accompanying client-reuse documentation.

No open issues 🎉

What changed in this PR

本 PR 将公众号 Spring Boot Starter 的 Redis host 默认值改为 null,与 MiniApp 对齐,修复省略 host 时无法复用应用已有 RedissonClient 的初始化问题。

Changes:

  • 移除 host 的默认地址,使省略 host 的 Jedis/Redisson 模式复用容器中的对应客户端。
  • 更新属性注释和 README,说明客户端复用行为,并区分显式配置示例与默认值。

验证:PR 描述记录了编译通过;本次未执行构建或测试。

File Description
spring-boot-starters/​wx-java-mp-spring-boot-starter/​src/​main/​java/​com/​binarywang/​spring/​starter/​wxjava/​mp/​properties/​RedisProperties.java 移除 host 默认值,并补充客户端复用说明。
spring-boot-starters/​wx-java-mp-spring-boot-starter/​README.md 说明 host 为显式配置示例及省略时的行为。

Review effort: Balanced

@binarywang
binarywang merged commit a311095 into binarywang:develop Nov 14, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants