weblogic下用@Resource出现No unique bean of type [cn.xx.dao.QueryDAO] is defined的解决办法 原创 2014年06月04日 16:1
来源:互联网 发布:php static class 编辑:程序博客网 时间:2024/05/22 04:50
weblogic下用@Resource出现No unique bean of type [cn.xx.dao.QueryDAO] is defined的解决办法
最近在使用weblogic时,出现各种问题,其中,有一个问题是这样,在某一个类中,通过@Resource注入一个DAO时,在tomcat时,没有问题,但是在weblogic下,就会出现以下错误:
Caused by: com.bea.core.repackaged.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [cn.xx.dao.QueryDAO] is defined: No beans of type cn.xx.dao.QueryDAO; owner=com.bea.core.repackaged.springframework.context.support.GenericApplicationContext@1af4318: display name [com.bea.core.repackaged.springframework.context.support.GenericApplicationContext@1af4318]; startup date [Wed Jun 04 16:06:59 CST 2014]; parent: com.bea.core.repackaged.springframework.context.support.GenericApplicationContext@11a4ce8
at com.oracle.pitchfork.inject.Jsr250Metadata.getUniqueInstanceOfType(Jsr250Metadata.java:354)
at com.oracle.pitchfork.inject.Jsr250Metadata.resolveByType(Jsr250Metadata.java:348)
at com.oracle.pitchfork.inject.Jsr250Metadata.resolve(Jsr250Metadata.java:278)
at com.oracle.pitchfork.inject.Jsr250Metadata.applyInjections(Jsr250Metadata.java:231)
试了各种方法:
办法1:
将以下代码
@Resource("queryDAO")
public QueryDAO queryDAO;
修改为
@Autowired(required = false)
@Qualifier("queryDAO")
public QueryDAO queryDAO;
办法2:
出现这个问题的根本原因,其实还是因为weblogic加载jar包时,默认加载weblogic自己的jar包,但是其jar包版本过低,所以根本解决办法是:
修改WEB-INF下的weblogic.xml,我的工程的weblogic.xml的完整代码为:
关键代码为<wls:package-name>javax.annotation.*</wls:package-name>- weblogic下用@Resource出现No unique bean of type [cn.xx.dao.QueryDAO] is defined的解决办法 原创 2014年06月04日 16:1
- weblogic下用@Resource出现No unique bean of type [cn.xx.dao.QueryDAO] is defined的解决办法
- No unique bean of type [com.yuanv.backstage.dao.SysUserDao] is defined: expected single matching bea
- No unique bean of type [ *.service.*Service] is defined
- No unique bean of type [javax.persistence.EntityManagerFactory] is defined
- No unique bean of type is defined: expected single bean but found 0
- No qualifying bean of type [] is defined
- No unique bean of type [net.shougongfang.action.paymoney.AlipayPayMoneyReturnObj] is defined: Unsat
- 关于dao层Bean注入失败报No qualifying bean of type [xxx.xxx.xxx.xxx] is defined错误的问题
- No qualifying bean of type xxxxx is defined
- Spring两个数据源配置在容器启动出错,No unique bean of type [org.springframework.jdbc.core.JdbcTemplate] is defined:
- No unique bean of type
- No unique bean of type
- No qualifying bean of type is defined: expected single matching bean but found 2
- spring启动时报错No qualifying bean of type【bean 】 is defined
- spring exception--No unique bean of type
- BeanCreationException: No unique bean of type
- Spring注解No unique bean of type
- 网络库libevent在Visual Studio中的使用方法
- C语言预习笔记(预处理和结构体)
- xshell常用命令
- Java中==和equals的区别
- BGP路由选路规则 —Huawei
- weblogic下用@Resource出现No unique bean of type [cn.xx.dao.QueryDAO] is defined的解决办法 原创 2014年06月04日 16:1
- windows7原版镜像下载地址分享
- KDnuggets整理最新机器学习必备十大入门算法!都在这里了
- 将jar包导入本地仓库
- 欢迎使用CSDN-markdown编辑器
- SQLServer 提示
- ofbiz实战5——创建学期管理新建和编辑页面
- 【BigHereo 26】-----Summary My Examnation Days
- Git使用之码云的操作步骤