下面为为配置文件,<!--                                            -->这个上面的能通过,就是加了<!--                                            -->下面的bean后后tomcat就出错,报的错我也在下面粘了。报set get错 但是在java类中已经配置。第二个action什么的我没写,我认为这不是主要问题。
<?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:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd"> <bean id="dataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="url">
<value>jdbc:mysql://localhost:3306/ps</value>
</property>
<property name="username">
<value>root</value>
</property>
<property name="password">
<value>pwd</value>
</property>
</bean>
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="dataSource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">false</prop>
</props>
</property>
<property name="mappingResources">
<list>
<value>com/jpresearch/po/Ddm_demand.hbm.xml</value>
</list>
</property>
</bean>
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory">
<ref bean="sessionFactory" />
</property>
</bean>
<bean id="researchDAOTarget" class="com.jpresearch.dao.impl.ResearchDAOImpl">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="hibernateTransactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"></ref>
</property>
</bean>
<bean id="researchDAO"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="hibernateTransactionManager"></ref>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
<property name="target">
<ref bean="researchDAOTarget"></ref>
</property> </bean>
<bean id="researchLogic" class="com.jpresearch.logic.impl.ResearchLogicImpl">
<property name="researchDAO" ref="researchDAO"></property>
</bean>
<bean id="researchService" class="com.jpresearch.service.impl.ResearchServiceImpl">
<property name="researchLogic" ref="researchLogic"></property>
</bean> <bean id="isearch" class="com.jpresearch.action.ISearch">
<property name="researchService" ref="researchService"></property>
</bean>
<!--                                            -->
<bean id="ADAOTarget" class="com.jpresearch.dao.impl.ADAOImpl">
<property name="hibernateTemplate">
<ref bean="hibernateTemplate" />
</property>
</bean>
<bean id="ADAO"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="hibernateTransactionManager"></ref>
</property>
<property name="transactionAttributes">
<props>
<prop key="*">PROPAGATION_REQUIRED</prop>
</props>
</property>
<property name="target">
<ref bean="ADAOTarget"></ref>
</property> </bean>
<bean id="ALogic" class="com.jpresearch.logic.impl.ALogicImpl">
<property name="ADAO" ref="ADAO"></property>
</bean></beans>
致命的: Context initialization failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'viewLogic' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property '1' of bean class [com.jpresearch.logic.impl.ViewLogicImpl]: Bean property '1' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?

解决方案 »

  1.   

    你看看com.jpresearch.logic.impl.ViewLogicImpl这个类里的viewLogic赋的值是什么。get方法与set方法的参数类型是不是不一致,“Does the parameter type of the setter match the return type of the getter”
      

  2.   

     'viewLogic'这个类的配置有问题,applicationContext.xml
    再仔细检查一遍看看。
      

  3.   

    报的ViewLogicImpl这个bean创建错误,但在你的配置文件也没有配置ViewLogicImpl啊,什么情况?