Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

jdk21模块化项目集成nacos.client报错 #12551

Closed
aszdKing opened this issue Aug 26, 2024 · 13 comments
Closed

jdk21模块化项目集成nacos.client报错 #12551

aszdKing opened this issue Aug 26, 2024 · 13 comments
Labels
area/Client Related to Nacos Client SDK kind/enhancement Category issues or prs related to enhancement.

Comments

@aszdKing
Copy link

编译报错 java: 找不到模块: nacos.client

@aszdKing aszdKing changed the title 模块化项目集成nacos.client报错 jdk21模块化项目集成nacos.client报错 Aug 26, 2024
@luxiao0000
Copy link
Contributor

因为模块命名为com.google.gson,在META-INF/version/9/module-info中,😮‍💨

@luxiao0000
Copy link
Contributor

不理解官方为何如此命名

@KomachiSion
Copy link
Collaborator

没看懂问题,麻烦提供更详细的描述和报错上下文信息。

@luxiao0000
Copy link
Contributor

对比fastjson2,一看就明白
image
image

@luxiao0000
Copy link
Contributor

原因我想我明白了,maven-shade-plugin插件打包时会把gson里的模块化描述文件带过来,导致nacos-client错误的使用了gson的模块化描述文件

@KomachiSion
Copy link
Collaborator

还是没明白, 这个shaded进来的描述文件会影响什么?

@luxiao0000
Copy link
Contributor

就会导致当前issues的问题,shade阶段不会编译,只是二次打包,所以不会暴露问题,https://openjdk.org/jeps/201。复现方法,构建一个模块化工程,requires nacos-client就会复现问题

@luxiao0000
Copy link
Contributor

image image 2.0.0和2.4.1正好能做对比

@KomachiSion
Copy link
Collaborator

还是没太理解。 2.0.0也使用了shaded,为什么没有问题呢。

@luxiao0000
Copy link
Contributor

2.0.0依赖的gson还没有模块化,所以没有问题

@KomachiSion
Copy link
Collaborator

2.0.0依赖的gson还没有模块化,所以没有问题

那有办法修复吗

@luxiao0000
Copy link
Contributor

shaded排除掉所有的模块描述文件,因为也不确定后续哪个依赖突然模块化了

@luxiao0000
Copy link
Contributor

luxiao0000 commented Sep 18, 2024

#12660

@KomachiSion KomachiSion added area/Client Related to Nacos Client SDK kind/enhancement Category issues or prs related to enhancement. and removed status/invalid This doesn't seem right status/need feedback labels Sep 27, 2024
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
area/Client Related to Nacos Client SDK kind/enhancement Category issues or prs related to enhancement.
Projects
None yet
Development

No branches or pull requests

3 participants