struts+spring+hibernate找不到bean....

bluesmile發表於2008-04-15
錯誤提示:javax.servlet.ServletException: Error creating bean with name '/notice' defined in ServletContext resource [/WEB-INF/action-servlet.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property 'noticeManager' of bean class [web.action.NoticeAction]: Bean property
都說是Spring配置的問題。。。。 但是我查不到。。。。 是照著例子做的 覺得沒什麼和例子不同的地方啊。。。

配置檔案如下:


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>

	<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/book</value>
		</property>

		<property name="username">
			<value>root</value>
		</property>

		<property name="password">
			<value>root</value>
		</property>

	</bean>

	<bean id="sessionFactory"
		class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
		<property name="dataSource">
			<ref bean="dataSource" />
		</property>

		<property name="mappingDirectoryLocations">
			<list>
				<value>WEB-INF/classes/dao/model</value>
			</list>
		</property>

		<property name="hibernateProperties">

			<props>
				<prop key="hibernate.dialect">
					org.hibernate.dialect.MySQLDialect
				</prop>

				<prop key="hibernate.show_sql">false</prop>
			</props>
		</property>
	</bean>

	<bean id="transactionManager"
		class="org.springframework.orm.hibernate3.HibernateTransactionManager">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>


  <!-- **************************** add the conf********************************** -->

    <bean id="noticeDao" 
           class="dao.dao.hibernate.NoticeDaoHibernate">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean>

	<bean id="noticeManagerTarget"
		class="service.impl.NoticeManagerImpl">
		<property name="noticeDao" ref="noticeDao" />
	</bean>


	<!-- ********************Transaction Configration***************************** -->

	
	
	<!-- *****************************************************add the back************************************************** -->
		<bean id="noticeManager"
		class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
		<property name="transactionManager">
			<ref bean="transactionManager" />
		</property>

		<property name="target">
			<ref local="noticeManagerTarget" />
		</property>
		<property name="transactionAttributes">
			<props>
				<prop key="find*">PROPAGATION_REQUIRED</prop>
				<prop key="get*">PROPAGATION_REQUIRED,readOnly</prop>
				<prop key="save*">PROPAGATION_REQUIRED</prop>
				<prop key="remove*">PROPAGATION_REQUIRED</prop>
				<prop key="insert*">PROPAGATION_REQUIRED</prop>
				<prop key="update*">PROPAGATION_REQUIRED</prop>
				<prop key="*">PROPAGATION_REQUIRED</prop>
			</props>
		</property>
	</bean>

	
<!-- *************************************************add the back end******************************************************** -->
	
</beans>



// 在此輸入java程式碼
<p class="indent">

// 在此輸入java程式碼
<p class="indent">

// 在此輸入java程式碼
<p class="indent">

相關文章