weblogic下用@Resource出现No unique bean of type [cn.xx.dao.QueryDAO] is defined的解决办法
2014-06-04 16:16
786 查看
最近在使用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的完整代码为:
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的完整代码为:
<?xml version="1.0" encoding="UTF-8"?> <wls:weblogic-web-app xmlns:wls="http://xmlns.oracle.com/weblogic/weblogic-web-app" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd http://xmlns.oracle.com/weblogic/weblogic-web-app http://xmlns.oracle.com/weblogic/weblogic-web-app/1.4/weblogic-web-app.xsd"> <wls:container-descriptor> <wls:prefer-application-packages> <wls:package-name>com.google.common.*</wls:package-name> <wls:package-name>javax.jws.soap.*</wls:package-name> <wls:package-name>javax.xml.ws.*</wls:package-name> <wls:package-name>javax.annotation.*</wls:package-name> </wls:prefer-application-packages> </wls:container-descriptor> <wls:resource-env-description> <wls:resource-env-ref-name>queryDAO</wls:resource-env-ref-name> <wls:jndi-name>dataSource</wls:jndi-name> </wls:resource-env-description> <wls:resource-env-description> <wls:resource-env-ref-name>updateDAO</wls:resource-env-ref-name> <wls:jndi-name>dataSource</wls:jndi-name> </wls:resource-env-description> </wls:weblogic-web-app>关键代码为<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
- No unique bean of type [com.yuanv.backstage.dao.SysUserDao] is defined: expected single matching bea
- MyBatis映射错误,No qualifying bean of type 'xx.xx.UserDao' available
- springmvc注入类 NoUniqueBeanDefinitionException: No qualifying bean of type [] is defined: expected single错误
- No unique bean of type [xxxxx] is defined: expected single bean but...
- No qualifying bean of type 'com.funo.oa.dao.PostDao' available问题解决:找不到dao的实现类
- No unique bean of type [net.shougongfang.action.paymoney.AlipayPayMoneyReturnObj] is defined: Unsat
- 解决“No qualifying bean of type found for dependency”办法
- 出现No qualifying bean of type [com.*.*.dao.InfoDao] found for :错误
- No unique bean of type [ *.service.*Service] is defined
- No unique bean of type [javax.persistence.EntityManagerFactory] is defined
- No unique bean of type [net.shougongfang.action.paymoney.AlipayPayMoneyReturnObj] is defined: Unsat
- Spring两个数据源配置在容器启动出错,No unique bean of type [org.springframework.jdbc.core.JdbcTemplate] is defined:
- No matching bean of type [xx] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency
- 关于[[NSBundle mainBundle] pathForResource:@"name" ofType:@"type"]找不到指定文件的解决办法
- No qualifying bean of type [javax.persistence.EntityManage] 异常问题的解决
- Spring4.14 事务异常 NoUniqueBeanDefinitionException: No qualifying bean of type [....PlatformTransactionManager]
- warning C4150: deletion of pointer to incomplete type 'xxx'; no destructor called 的解决办法
- No getter method for property * of bean * 解决办法
- No unique bean of type