无法为Eclipse 2022-09安装GWT插件,如何解决依赖缺失问题?
解决Eclipse 2022-09安装GWT 2.8.1插件时缺失javax.servlet依赖的问题
问题背景
使用Eclipse IDE for Enterprise Java and Web Developers - 2022-09版本,尝试安装GWT 2.8.1 SDK插件时安装失败,核心错误为插件依赖的osgi.bundle; javax.servlet 0.0.0无法找到。完整错误日志如下:
Cannot complete the install because one or more required items could not be found. Software being installed: GWT 2.8.1 SDK 2.8.0.201710131939 (com.gwtplugins.eclipse.sdkbundle.gwt28.feature.feature.group 2.8.0.201710131939) Missing requirement: GWT Eclipse Platform Plugin 3.0.0.201710131939 (com.gwtplugins.gdt.eclipse.platform 3.0.0.201710131939) requires 'osgi.bundle; javax.servlet 0.0.0' but it could not be found Cannot satisfy dependency: From: GWT 2.8.1 SDK 2.8.0.201710131939 (com.gwtplugins.eclipse.sdkbundle.gwt28.feature.feature.group 2.8.0.201710131939) To: org.eclipse.equinox.p2.iu; com.gwtplugins.gwt.eclipse.sdkbundle.gwt28 [2.8.0.201710131939,2.8.0.201710131939] Cannot satisfy dependency: From: GWT Development Tools Core Plugin 3.0.0.201710131939 (com.gwtplugins.gdt.eclipse.core 3.0.0.201710131939) To: osgi.bundle; com.gwtplugins.gdt.eclipse.platform 0.0.0 Cannot satisfy dependency: From: GWT Eclipse Plugin 3.0.0.201710131939 (com.gwtplugins.gwt.eclipse.core 3.0.0.201710131939) To: osgi.bundle; com.gwtplugins.gdt.eclipse.core 0.0.0 Cannot satisfy dependency: From: com.gwtplugins.gwt.eclipse.sdkbundle.gwt28 2.8.0.201710131939 To: osgi.bundle; com.gwtplugins.gwt.eclipse.core 0.0.0
问题根源是旧版GWT插件依赖的javax.servlet包在Eclipse 2022-09中已被替换为Jakarta EE规范下的jakarta.servlet,导致依赖无法匹配。
解决方案
方法1:补充安装Eclipse Java EE组件
- 打开Eclipse,依次点击Help > Install New Software
- 在「Work with」下拉框中选择当前Eclipse版本的官方更新站点(2022-09版本对应站点为
https://download.eclipse.org/releases/2022-09) - 在搜索框输入Servlet,勾选「Eclipse Java EE Developer Tools」下的Servlet相关组件,直接勾选整个「Eclipse Java EE Developer Tools」组件也可
- 按照向导完成安装,重启Eclipse后再次尝试安装GWT插件
方法2:手动导入javax.servlet OSGi包
- 下载带有OSGi元数据的
javax.servlet-apijar包(推荐3.1.0版本) - 打开Eclipse,依次点击File > Import > Plug-in Development > Plug-ins and Fragments
- 选择下载好的jar包,导入为插件项目
- 右键导入的项目,选择Export > Plug-in Development > Deployable plug-ins and fragments,设置输出目录并勾选「Generate metadata repository」,导出为本地更新站点
- 回到Install New Software,添加刚才导出的本地更新站点,安装该javax.servlet插件后再尝试安装GWT插件
方法3:升级到兼容新版本Eclipse的GWT插件
GWT 2.8.1的插件发布于2017年,完全不兼容Eclipse 2022-09。建议安装适配新Eclipse版本的GWT插件:
- 在Install New Software中添加GWT插件的最新更新站点(如适配Eclipse 2022+的GWT 4.x版本站点)
- 选择适配当前Eclipse的GWT SDK和插件组件完成安装
方法4:临时禁用依赖检查(不推荐)
- 找到Eclipse安装目录下的
eclipse.ini文件,用文本编辑器打开 - 在
-vmargs段落添加以下参数:-Dorg.eclipse.equinox.p2.resolve=false - 保存文件后重启Eclipse,尝试重新安装GWT插件
注意:此方法会跳过所有依赖检查,可能引发其他插件兼容性问题,仅作为临时应急方案使用
内容的提问来源于stack exchange,提问作者Polymood
相关产品推荐
相关产品推荐

