对java有感觉 2011-10-24 16:44 采纳率: 0%
浏览 180
已采纳

spring配置问题

这个是我的spring配置文件
<?xml version="1.0" encoding="UTF-8"?>
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">

<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
    <property name="url"
        value="jdbc:mysql://localhost:3306/houseproject?useUnicode=true&amp;characterEncoding=UTF-8"></property>
    <property name="username" value="root"></property>
    <property name="password" value=""></property>
    <property name="maxActive" value="100"></property>
    <property name="maxIdle" value="30"></property>
    <property name="maxWait" value="500"></property>
    <property name="defaultAutoCommit" value="true"></property>
</bean>
<bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource"></property>
    <property name="hibernateProperties">
        <props>
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
            <prop key="hibernate.show_sql">true</prop>
        </props>
    </property>
    <property name="mappingResources">
        <list>
            <value>org/shj/houseproject/pojo/Users.hbm.xml</value>
            <value>org/shj/houseproject/pojo/Area.hbm.xml</value>
            <value>org/shj/houseproject/pojo/House.hbm.xml</value>
            <value>org/shj/houseproject/pojo/Street.hbm.xml</value>
        </list>
    </property>
</bean>
<!-- 事务处理 固定模式 -->
<bean id="transactionManager"
    class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>
<tx:advice id="txAdvicehouse" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="list" propagation="REQUIRED" />
        <!--对name对应的方法进行事务处理  -->
        <!--
            <tx:method name="ad*" propagation="REQUIRED" /> <tx:method
            name="del*" propagation="REQUIRED" /> <tx:method name="upd*"
            propagation="REQUIRED" /> <tx:method name="findBy*"
            propagation="REQUIRED" />
        -->
    </tx:attributes>
</tx:advice>
<!--设置切点 -->
<aop:config>
    <aop:pointcut id="allManagerMethodhouse" expression="execution(* org.shj.houseproject.houseService.*.*(..))" />
    <aop:advisor advice-ref="txAdvicehouse" pointcut-ref="allManagerMethodhouse" />
</aop:config>


<!-- 设置login切面通知 -->
<tx:advice id="txAdvicelogin" transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="log*" propagation="REQUIRED" />
    </tx:attributes>
</tx:advice>
<!-- 设置切点 -->
<aop:config>
    <!-- 设置对那个包里面的类里面的方法进行代理 这样就精确到了一个方法 也就是一个切点-->
    <aop:pointcut id="allManagerMethodlogin"
        expression="execution(* org.shj.houseproject.loginService.*.*(..))" />
    <!--这个就是将切点和通知结合起来桥梁 这样就可以进行代理了  -->
    <!--箭头只是代表的标记作用  -->
    <aop:advisor advice-ref="txAdvicelogin" pointcut-ref="allManagerMethodlogin" />

</aop:config>

<!--
    将sessionfactory注入到logindaoimpl中里面 为什么代码里面没有写sessionFactory
    因为logindaoimpl是继承HibernateDaoSupport
-->
<bean id="loginDAOImpl" class="org.shj.houseproject.login.dao.LoginDAOImpl">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>
<!-- 将loginDAO注入到logindaoserviceImpl中  -->
<bean id="loginManager" class="org.shj.houseproject.login.Service.LoginServiceImpl">
    <property name="logindaoi">
        <ref bean="loginDAOImpl" />
    </property>
</bean>
<!-- 将loginserviceImpl注入到Action -->
<bean id="loginAction" class="org.shj.houseproject.login.action.LoginAction">
    <property name="longinservice">
        <ref bean="loginManager" />
    </property>
</bean>
<bean id="houseDAOImpl" class="org.shj.houseproject.login.dao.LoginDAOImpl">
    <property name="sessionFactory">
        <ref bean="sessionFactory" />
    </property>
</bean>
<bean id="houseService" class="org.shj.houseproject.houseService.HouseServiceImpl">
    <property name="housedao">
        <ref bean="houseDAOImpl" />
    </property>
</bean>
<bean id="HouseAction" class="org.shj.houseproject.house.action.HouseAction">
    <property name="houseservice">
        <ref bean="houseService" />
    </property>
</bean>

出现下面异常
严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'houseManager' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type 'org.shj.houseproject.login.dao.LoginDAOImpl' to required type 'org.shj.houseproject.house.dao.IHouseDAO' for property 'housedao'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [org.shj.houseproject.login.dao.LoginDAOImpl] to required type [org.shj.houseproject.house.dao.IHouseDAO] for property 'housedao': no matching editors or conversion strategy found
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:521)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:450)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:290)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:287)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:189)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:562)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:871)
at org.springframewo
求解决 搞了一下午了解决不了求大家帮忙

  • 写回答

1条回答 默认 最新

  • DreamZhong 2011-10-24 17:45
    关注

    [quote]



    [/quote]

    晕,你的class写错了,你写的LoginDAOImpl,因为你要定义的是HouseDAOImpl,所以我想你应该有另一个HouseDAOImpl类吧,改成这个定义。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?