You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Java8 Eclipse OSGI项目更新nebula组件后Maven构建失败求助

问题描述

现有一个基于Java 8的旧OSGI项目,2022年8月将org.eclipse.nebula.widgets.formattedtext组件更新至版本1.0.0.202208171905后,Maven构建失败;此前的1.0.0.202205212120版本可正常构建。

更新后出现如下构建错误:

[ERROR] Cannot resolve project dependencies:
[ERROR] Software being installed: com.company.product 1.2.3.qualifier
[ERROR] Missing requirement: org.eclipse.nebula.widgets.formattedtext 1.0.0.202208171905 requires 'osgi.ee; (&(osgi.ee=JavaSE)(version=11))' but it could not be found
[ERROR] Cannot satisfy dependency: com.company.product 1.2.3.qualifier depends on: osgi.bundle; org.eclipse.nebula.widgets.formattedtext 1.0.0
[ERROR]
[ERROR] See http://wiki.eclipse.org/Tycho/Dependency_Resolution_Troubleshooting for help.
[ERROR] Cannot resolve dependencies of MavenProject: com.company.product:com.company.product:1.2.3-SNAPSHOT @ C:\dev\designer\com.company.product\pom.xml: See log for details -> [Help 1]

请问需要修改哪些内容才能恢复正常构建?

解决方案

错误核心是升级后的org.eclipse.nebula.widgets.formattedtext版本要求Java SE 11运行环境,但项目基于Java 8,导致依赖无法解析。可通过以下两种方式解决:

方式一:降级nebula组件版本

将org.eclipse.nebula.widgets.formattedtext的版本回退至之前可正常构建的1.0.0.202205212120:

  • 找到项目POM文件中该组件的依赖配置,修改版本号为1.0.0.202205212120
  • 若项目使用OSGI的feature或bnd文件管理依赖,同步修改对应位置的版本号

方式二:升级项目至Java 11

如果需要保留新版本的nebula组件,需将整个项目的Java版本升级到11:

  1. 修改Maven编译配置:在POM文件中更新maven-compiler-plugin的source和target参数为11:
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>
        <configuration>
            <source>11</source>
            <target>11</target>
        </configuration>
    </plugin>
    
  2. 更新Tycho配置:若使用Tycho构建,需在POM或target-platform-configuration中指定Java 11的OSGI执行环境:
    <plugin>
        <groupId>org.eclipse.tycho</groupId>
        <artifactId>target-platform-configuration</artifactId>
        <version>${tycho.version}</version>
        <configuration>
            <executionEnvironment>JavaSE-11</executionEnvironment>
        </configuration>
    </plugin>
    
  3. 检查依赖兼容性:确认项目中其他OSGI组件、第三方库均支持Java 11,避免新的依赖冲突
  4. 调整构建环境:将本地构建环境和CI/CD服务器的JDK版本切换为11

内容的提问来源于stack exchange,提问作者OGP

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.19 21:55:27