CDI部署失败:WELD-001414 Bean名称不明确 [英] CDI deployment failure:WELD-001414 Bean name is ambiguous

查看:357
本文介绍了CDI部署失败:WELD-001414 Bean名称不明确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,它具有多个模块和各种依赖性.当我在Glassfish 4上部署应用程序时,出现错误:

I have an application, which has multiple modules and various dependencies. When I deploy the application on Glassfish 4, I am getting error:

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,而仅仅是依赖项.如何避免这种例外情况?

What can be the cause? I saw already topics about this and the solution was to edit the annotation but this is not my EJB, just a dependency. How can I avoid this exception?

我正在将Java EE 6与JDK 1.7和Glassfish 4.0一起使用.

I am using Java EE 6 with JDK 1.7 and Glassfish 4.0.

推荐答案

Glassfish已经为您打包了Jerseys库,因此您需要按照

Glassfish is already having Jerseys libraries packaged for you, so you need add provided scope into your Maven pom.xml as stated in the docs.

<dependency>
    <groupId>javax.ws.rs</groupId>
    <artifactId>javax.ws.rs-api</artifactId>
    <version>2.0</version>
    <scope>provided</scope>
</dependency>

如果您使用的是Jersey的任何特定功能,则需要直接依赖Jersey.

If you are using any Jersey specific feature, you will need to depend on Jersey directly.

<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>

这篇关于CDI部署失败:WELD-001414 Bean名称不明确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆