求大家帮忙,小弟初学者!
我在UserAction中的内容是
private IUserService userservice;
//依赖注入业务逻辑组件
public void setUserservice(IUserService userservice) {
this.userservice = userservice;
}
配置文件如下
<?xml version="1.0" encoding="UTF-8"?>
<beans
 xmlns="http://www.springframework.org/schema/beans"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
 xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
 xsi:schemaLocation="
            http://www.springframework.org/schema/beans 
            http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
            http://www.springframework.org/schema/aop 
            http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
            http://www.springframework.org/schema/tx 
            http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
            http://www.springframework.org/schema/context 
            http://www.springframework.org/schema/context/spring-context-3.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/mydb"></property>
<property name="username" value="root"></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.MySQLDialect
</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>app/model/Users.hbm.xml</value>
<value>com/portal/user/model/User.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="txAdvice" transaction-manager="transactionManager">
 <tx:attributes>
 <tx:method name="save*" propagation="REQUIRED" />
 <tx:method name="update*" propagation="REQUIRED" />
 <tx:method name="delete*" propagation="REQUIRED" />
 <tx:method name="add*" propagation="REQUIRED" />
 <tx:method name="del*" propagation="REQUIRED" />
 <tx:method name="*" read-only="true" />
 </tx:attributes>
    </tx:advice>
    <!-- 哪些类的方法参与事物 -->
    
    <aop:config>
 <aop:pointcut id="allServiceMethod" expression="execution(* app.service.*.*(..))" />
 <aop:advisor pointcut-ref="allServiceMethod" advice-ref="txAdvice" />
    </aop:config>
<!--项目的开发  -->
<!-- 用户Bean的-->
<bean id="UserDAO" class="com.portal.user.dao.UserDAO">
     <property name="sessionFactory">
     <ref bean="sessionFactory"></ref>
     </property>
    </bean>
    <!-- 部署业务逻辑组件,并把它所依赖的DAO组件注入到业务逻辑组件中 -->
    <bean id="UserService" class="com.portal.user.service.UserService">
     <property name="userDAO" ref="UserDAO"></property>
    </bean>
    <!-- 把业务逻辑组件注入到Action中 -->
    <bean id="UserAction" class="com.portal.user.web.UserAction">
     <property name="userservice" ref="UsersService"></property>
    </bean>
</beans>异常如下啊:
严重: 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 'UserAction' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing app.service.IUsersService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'com.portal.user.service.IUserService' for property 'userservice'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing app.service.IUsersService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.portal.user.service.IUserService] for property 'userservice': 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.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:423)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:272)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:196)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4172)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4671)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:546)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1041)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:964)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:502)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1277)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:321)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1061)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:785)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1053)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:701)
at org.apache.catalina.startup.Catalina.start(Catalina.java:585)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
Caused by: org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing app.service.IUsersService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'com.portal.user.service.IUserService' for property 'userservice'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing app.service.IUsersService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.portal.user.service.IUserService] for property 'userservice': no matching editors or conversion strategy found
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:462)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.convertForProperty(AbstractAutowireCapableBeanFactory.java:1354)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1313)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1067)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:511)
... 35 more
Caused by: java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing app.service.IUsersService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.portal.user.service.IUserService] for property 'userservice': no matching editors or conversion strategy found
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:289)
at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:154)
at org.springframework.beans.BeanWrapperImpl.convertForProperty(BeanWrapperImpl.java:452)
... 39 more

解决方案 »

  1.   

    其实就是只句话:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'UserAction' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException: Failed to convert property value of type '$Proxy4 implementing app.service.IUsersService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised' to required type 'com.portal.user.service.IUserService' for property 'userservice'; nested exception is java.lang.IllegalStateException: Cannot convert value of type [$Proxy4 implementing app.service.IUsersService,org.springframework.aop.SpringProxy,org.springframework.aop.framework.Advised] to required type [com.portal.user.service.IUserService] for property 'userservice': no matching editors or conversion strategy found
      

  2.   

    UserDAO UserService确定定义的是接口?
      

  3.   

    他们是实现类,接口是IUserDAO,IUserService
      

  4.   

    UsersService   你action注入的时候  应该是UserService
      

  5.   

    我怎么感觉 <aop:config>
             <aop:pointcut id="allServiceMethod" expression="execution(* app.service.*.*(..))" />
             <aop:advisor pointcut-ref="allServiceMethod" advice-ref="txAdvice" />
        </aop:config>    这里不对
      

  6.   


    嗯嗯 发现了,谢谢我还发现了一个错误,expression="execution(* app.service.*.*(..)"我上网查的配置,就照搬过来了,,应该还要该成expression="execution(* com.portal.*.service.*.*(..) (有点不确定,我改了,没发现有错的,嘿嘿),才符合我的项目哎,初学就是只会照搬,我得加油了