ooppmm001 2016-11-07 07:20 采纳率: 0%
浏览 2289

新手求助spring一用注解就报错

@Repository("aadaoimpl")
public class aaimpl extends HibernateDaoSupport implements aadao
这是dao层的

@Service("aaservice")
public class aasrviceimpl implements aaservice

@Resource(name="aadaoimpl")
private aadao a;
这是Service层的

xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">

<context:component-scan base-package="com"></context:component-scan>

<bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName"
        value="oracle.jdbc.driver.OracleDriver">
    </property>
    <property name="url"
        value="jdbc:oracle:thin:@localhost:1521:orcl">
    </property>
    <property name="username" value="scott"></property>
    <property name="password" value="tiger"></property>
</bean>
<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource">
        <ref bean="dataSource"></ref>
    </property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">
                org.hibernate.dialect.OracleDialect
            </prop>
        </props>
    </property>
    <property name="mappingResources">
        <list>
            <value>com/java/pojo/aa.hbm.xml</value>
            </list>
    </property>
    </bean>




<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- 数据源
dataSource在applicationContext-dao.xml中配置了
 -->
<property name="dataSource" ref="dataSource"/>


tx:attributes
<!-- 传播行为 -->







/tx:attributes
/tx:advice

aop:config

/aop:config

这是我的spring配置文件信息

@Test
public void testShow() {
ApplicationContext ap=new ClassPathXmlApplicationContext("applicationContext.xml");
aaservice as=(aaservice) ap.getBean("aaservice");
aa ad=new aa();

    ad.setName("as");
    ad.setSex("f");
as.savea(ad);
}

最后就是我的测试信息

我用普通spring的方式注入就很好 但是换注解就报

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'aadaoimpl' defined in file

  • 写回答

3条回答 默认 最新

  • qq_36416875 2016-11-07 07:40
    关注

    配置mvc注解扫描了吗...

    评论

报告相同问题?

悬赏问题

  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突
  • ¥15 超声波模块测距控制点灯,灯的闪烁很不稳定,经过调试发现测的距离偏大
  • ¥15 import arcpy出现importing _arcgisscripting 找不到相关程序