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

Maven多模块引入jaxrs-api后Enunciate报错找不到InterceptorBinding类

报错根本原因

Enunciate插件执行编译任务时使用独立的类路径,你在项目主依赖中添加的javax.interceptor-api不会被自动加载到插件的运行环境中,因此即使添加了项目依赖也无法解决报错。

可行解决方案

  • 方案1:为Enunciate插件单独添加依赖
    在pom.xml的enunciate插件配置中显式引入拦截器API,示例配置如下:
<plugin>
  <groupId>com.webcohesion.enunciate</groupId>
  <artifactId>enunciate-maven-plugin</artifactId>
  <version>2.13.2</version>
  <executions>
    <execution>
      <goals>
        <goal>assemble</goal>
      </goals>
    </execution>
  </executions>
  <!-- 插件专属依赖 -->
  <dependencies>
    <dependency>
      <groupId>javax.interceptor</groupId>
      <artifactId>javax.interceptor-api</artifactId>
      <version>1.2.2</version>
    </dependency>
  </dependencies>
</plugin>
  • 方案2:替换JAX-RS API依赖
    当前使用的JBoss封装版jaxrs-api内置了对InterceptorBinding注解的隐式引用,如果你项目没有用到JBoss专属的扩展功能,可以替换为官方独立的JAX-RS API依赖,规避不必要的传递依赖问题:
<!-- 替换原来的org.jboss.resteasy:jaxrs-api依赖 -->
<dependency>
  <groupId>javax.ws.rs</groupId>
  <artifactId>javax.ws.rs-api</artifactId>
  <version>2.0</version>
</dependency>
  • 方案3:忽略编译检查
    如果项目全程没有用到InterceptorBinding相关功能,可以在Enunciate的配置文件enunciate.xml中添加参数关闭对应类缺失的报错:
<enunciate>
  <javac>
    <compilerArgument>-Xlint:-classfile</compilerArgument>
  </javac>
</enunciate>

额外注意事项

你提到使用的Enunciate版本为2.0.0,但报错日志中实际执行的插件版本为2.13.2,建议检查父pom或者依赖管理节点中的插件版本配置,统一版本可避免兼容性问题。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.10.07 13:18:02