我有一个应用程序,它有多个模块和各种依赖项。当我在 Glassfish 4 上部署应用程序时,出现错误:
org.jboss.weld.exceptions.DeploymentException: WELD-001414 Bean name is ambiguous.
Name JerseyClassAnalyzer resolves to beans: [Managed Bean [class org.glassfish.jersey.internal.inject.JerseyClassAnalyzer]
with qualifiers [@Default @Named @Any], Managed Bean
[class org.glassfish.jersey.internal.inject.JerseyClassAnalyzer]
with qualifiers [@Default @Named @Any]]
可能是什么原因?我已经看到了关于这个的主题,解决方案是编辑注释,但这不是我的 EJB
,只是一个依赖项。我怎样才能避免这个异常?
我正在使用带有 JDK 1.7 和 Glassfish 4.0 的 Java EE 6。
最佳答案
Glassfish 已经为您打包了 Jerseys 库,因此您需要将 provided
范围添加到您的 Maven pom.xml
中,如 docs 中所述.
<dependency>
<groupId>javax.ws.rs</groupId>
<artifactId>javax.ws.rs-api</artifactId>
<version>2.0</version>
<scope>provided</scope>
</dependency>
如果您正在使用任何 Jersey 特定功能,您将需要直接依赖 Jersey。
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.4.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.4.1</version>
<scope>provided</scope>
</dependency>
关于java - CDI部署失败:WELD-001414 Bean name is ambiguous,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20050266/