1、先帮我解决个错误
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDAO' defined in ServletContext resource [/WEB-INF/classes/com/flash/card/cfg/spring/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'sessionFactory' of bean class [com.flash.card.hibernatedao.UserDAO]: No property 'sessionFactory' found
2、由于这个架构是别人的,我不是很了解里面的各个属性配置的意义,想请高手在关键部分给个注释
3、如果我这个架构用在访问量较大的网站上,我还该注意哪些配置
讲的有道理和详细我会在加100分.几个配置文件
web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/com/flash/card/cfg/spring/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/classes/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.util.IntrospectorCleanupListener
</listener-class>
</listener>
<!--Begin spring2 bean scope: request,session,gloalSession配置, 针对servlet2.4及之后-->
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<!--End spring2 bean scope: request,session,gloalSession配置, 针对servlet2.4及之后-->
<servlet>
<servlet-name>jcaptcha</servlet-name>
<servlet-class>com.flash.card.common.ImageCaptchaServlet</servlet-class>
<load-on-startup>0</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>jcaptcha</servlet-name>
<url-pattern>/jcaptcha</url-pattern>
</servlet-mapping>
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>struts2-cleanup</filter-name>
<filter-class>org.apache.struts2.dispatcher.ActionContextCleanUp</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2-cleanup</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
<init-param>
<param-name>forceEncoding</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>*.html,*.jsp,*.do,*.action,*.*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping> <session-config>
<session-timeout>-1</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>/index.jsp</welcome-file>
</welcome-file-list>
</web-app>

解决方案 »

  1.   

    ===================================================================================
    applicationContext.xml
    <bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
    <list>
    <value>
    classpath:com/flash/card/cfg/spring/dbcon.properties
    </value>
    </list>
    </property>
    </bean> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close" abstract="false" scope="singleton"
    lazy-init="default" autowire="default" dependency-check="default">
    <property name="driverClass" value="${jdbc.driverClassName}" />
    <property name="jdbcUrl" value="${jdbc.url}" />
    <property name="user" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="maxPoolSize" value="20" />
    <property name="minPoolSize" value="10" />
    <property name="initialPoolSize" value="10" />
    <property name="maxIdleTime" value="25000" />
    <property name="acquireIncrement" value="2" />
    <property name="maxStatements" value="0" />
    <property name="idleConnectionTestPeriod" value="1800" />
    <property name="acquireRetryAttempts" value="30" />
    <property name="breakAfterAcquireFailure" value="true" />
    <property name="testConnectionOnCheckout" value="false" />
    </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="mappingDirectoryLocations">
    <list>
    <value>classpath:/com/flash/card/cfg/hibernate</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.format_sql">true</prop>
    <prop key="hibernate.use_sql_comments">true</prop>
    <prop key="hibernate.current_session_context_class">thread</prop>
    <prop key="hibernate.generate_statistics">true</prop>
    <prop key="hibernate.hbm2dll.auto">update</prop>
    <prop key="hibernate.jdbc.batch_size">20</prop>
    <prop key="hibernate.max_fetch_depth">50</prop>
    <prop key="hiberanate.characterEncoding">utf-8</prop>
    <prop key="hibernate.default_schema">dbo</prop>
    <prop key="hibernate.cache.use_query_cache">true</prop>
    <prop key="hibernate.cache.use_second_level_cache">true</prop>
    <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</prop>
    <prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
    <prop key="hibernate.query.substitutions">true 1, false 0, yes 'Y', no 'N'</prop>
    <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
    <prop key="hibernate.use_outer_join">true</prop>
    <prop key="hibernate.prepare_sql">true</prop>
    <prop key="hibernate.connection.release_mode">auto</prop>
    <prop key="hibernate.autoReconnect">true</prop>
    <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
    <prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop>
    </props>
    </property>
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean> <bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
    <property name="dataSource"><ref bean="dataSource" /></property>
    </bean>
    <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <!--baseTransactionProxy -->
    <bean id="baseTransactionProxy" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager"><ref bean="transactionManager" /></property>
    <property name="transactionAttributes">
    <props>
    <prop key="add*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="save*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="create*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="update*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="modify*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="get*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="find*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="remove*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="del*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="delete*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly,-tion</prop>
    </props>
    </property>
    <property name="preInterceptors">
    <list><ref local="hibernateInterceptor"/></list>
    </property>
    <property name="postInterceptors">
    <list><ref local="hibernateInterceptor"/></list>
    </property>
    </bean>
    <bean id="userDAO" class="com.flash.card.hibernatedao.UserDAO">
    <property name="sessionFactory">
    <ref bean="sessionFactory" />
    </property>
    </bean>
    <bean id="userService" parent="baseTransactionProxy">
    <property name="target">
    <bean class="com.flash.card.service.UserServiceImpl">
    <property name="userDAO" ref="userDAO" />
    </bean>
    </property>
    </bean>
    <bean id="userAction" class="com.flash.card.action.UserAction"
    scope="prototype">
    <property name="userService" ref="userService" />
    </bean>
    </beans>
    ==========================================================================================
    hibernate.cfg.xml
    <hibernate-configuration>
    <session-factory>
    <mapping resource="com/flash/card/cfg/hibernate/User.hbm.xml" />
    </session-factory>
    </hibernate-configuration>
      

  2.   

    我把我的几个文件从发一下
    1、先帮我解决个错误 
    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userDAO' defined in ServletContext resource [/WEB-INF/classes/com/flash/card/cfg/spring/applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.InvalidPropertyException: Invalid property 'sessionFactory' of bean class [com.flash.card.hibernatedao.UserDAO]: No property 'sessionFactory' found 
    2、由于这个架构是别人的,我不是很了解里面的各个属性配置的意义,想请高手在关键部分给个注释 
    3、如果我这个架构用在访问量较大的网站上,我还该注意哪些配置 
    讲的有道理和详细我会在加100分.几个配置文件 web.xml<?xml version="1.0" encoding="UTF-8"?>
    <web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
    http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"> <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
    /WEB-INF/classes/com/flash/card/cfg/spring/applicationContext.xml
    </param-value>
    </context-param>
    <context-param>
    <param-name>log4jConfigLocation</param-name>
    <param-value>/WEB-INF/classes/log4j.properties</param-value>
    </context-param>
    <listener>
    <listener-class>
    org.springframework.web.context.ContextLoaderListener
    </listener-class>
    </listener>
    <listener>
    <listener-class>
    org.springframework.web.util.IntrospectorCleanupListener
    </listener-class>
    </listener>
    <!--Begin spring2 bean scope: request,session,gloalSession配置, 针对servlet2.4及之后-->
    <listener>
    <listener-class>
    org.springframework.web.context.request.RequestContextListener
    </listener-class>
    </listener>
    <!--End spring2 bean scope: request,session,gloalSession配置, 针对servlet2.4及之后-->
    <servlet>
    <servlet-name>jcaptcha</servlet-name>
    <servlet-class>com.flash.card.common.ImageCaptchaServlet</servlet-class>
    <load-on-startup>0</load-on-startup>
    </servlet> <servlet-mapping>
    <servlet-name>jcaptcha</servlet-name>
    <url-pattern>/jcaptcha</url-pattern>
    </servlet-mapping>
    <filter>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <filter-class>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    </filter-class>
    </filter>
    <filter-mapping>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <url-pattern>*.action</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <url-pattern>*.jsp</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <url-pattern>*.do</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>OpenSessionInViewFilter</filter-name>
    <url-pattern>*.hmt</url-pattern>
    </filter-mapping>
    <!-- 
    <filter>
    <filter-name>jsp_filter</filter-name>
    <filter-class>com.panva.pg.interceptor.JspFilter</filter-class>
    </filter>
    <filter-mapping>
    <filter-name>jsp_filter</filter-name>
    <url-pattern>*.jsp</url-pattern>
    </filter-mapping>

    -->
    <filter>
    <filter-name>struts2</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.FilterDispatcher
    </filter-class>
    </filter> <filter-mapping>
    <filter-name>struts2</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping> <filter>
    <filter-name>struts2-cleanup</filter-name>
    <filter-class>
    org.apache.struts2.dispatcher.ActionContextCleanUp
    </filter-class>
    </filter>
    <filter-mapping>
    <filter-name>struts2-cleanup</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping> <filter>
    <filter-name>encodingFilter</filter-name>
    <filter-class>
    org.springframework.web.filter.CharacterEncodingFilter
    </filter-class>
    <init-param>
    <param-name>encoding</param-name>
    <param-value>UTF-8</param-value>
    </init-param>
    <init-param>
    <param-name>forceEncoding</param-name>
    <param-value>true</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>*.html,*.jsp,*.do,*.action,*.*</url-pattern>
    </filter-mapping>
    <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern>/*</url-pattern>
    </filter-mapping>
    <!-- 
    <servlet>
    <servlet-name>dwr</servlet-name>
    <servlet-class>uk.ltd.getahead.dwr.DWRServlet</servlet-class>
    <init-param>
    <param-name>debug</param-name>
    <param-value>true</param-value>
    </init-param>
    </servlet>

    <servlet-mapping>
    <servlet-name>dwr</servlet-name>
    <url-pattern>/dwr/*</url-pattern>
    </servlet-mapping>

    <jsp-config>
    <taglib>
    <taglib-uri>/struts-tags</taglib-uri>
    <taglib-location>/WEB-INF/struts-tags.tld</taglib-location>
    </taglib>
    <taglib>
    <taglib-uri>/auth-tag</taglib-uri>
    <taglib-location>/WEB-INF/auth-tag.tld</taglib-location>
    </taglib>
    </jsp-config> -->
    <session-config>
    <session-timeout>-1</session-timeout>
    </session-config>
    <welcome-file-list>
    <welcome-file>/index.jsp</welcome-file>
    </welcome-file-list>
    </web-app>
      

  3.   

    applicationContext.xml<?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:util="http://www.springframework.org/schema/util"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                               http://www.springframework.org/schema/util
                               http://www.springframework.org/schema/util/spring-util-2.5.xsd
                               http://www.springframework.org/schema/aop
                               http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
    <import resource="classpath:com/flash/card/cfg/spring/spring_base.xml" />
    <import resource="classpath:com/flash/card/cfg/spring/user_spring.xml" />
    </beans>=================
    pring_base.xml<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
                               http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
                               http://www.springframework.org/schema/util
                               http://www.springframework.org/schema/util/spring-util-2.5.xsd
                               http://www.springframework.org/schema/aop
                               http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
    <bean
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="locations">
    <list>
    <value>
    classpath:com/flash/card/cfg/spring/dbcon.properties
    </value>
    </list>
    </property>
    </bean> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
    destroy-method="close" abstract="false" scope="singleton"
    lazy-init="default" autowire="default" dependency-check="default">
    <property name="driverClass" value="${jdbc.driverClassName}" />
    <property name="jdbcUrl" value="${jdbc.url}" />
    <property name="user" value="${jdbc.username}" />
    <property name="password" value="${jdbc.password}" />
    <property name="maxPoolSize" value="20" />
    <property name="minPoolSize" value="10" />
    <property name="initialPoolSize" value="10" />
    <property name="maxIdleTime" value="25000" />
    <property name="acquireIncrement" value="2" />
    <property name="maxStatements" value="0" />
    <property name="idleConnectionTestPeriod" value="1800" />
    <property name="acquireRetryAttempts" value="30" />
    <property name="breakAfterAcquireFailure" value="true" />
    <property name="testConnectionOnCheckout" value="false" />
    </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
    <property name="dataSource" ref="dataSource" />
    <property name="mappingDirectoryLocations">
    <list>
    <value>classpath:/com/flash/card/cfg/hibernate</value>
    </list>
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
    <prop key="hibernate.show_sql">true</prop>
    <prop key="hibernate.format_sql">true</prop>
    <prop key="hibernate.use_sql_comments">true</prop>
    <prop key="hibernate.current_session_context_class">thread</prop>
    <prop key="hibernate.generate_statistics">true</prop>
    <prop key="hibernate.hbm2dll.auto">update</prop>
    <prop key="hibernate.jdbc.batch_size">20</prop>
    <prop key="hibernate.max_fetch_depth">50</prop>
    <prop key="hiberanate.characterEncoding">utf-8</prop>
    <prop key="hibernate.default_schema">dbo</prop>
    <prop key="hibernate.cache.use_query_cache">true</prop>
    <prop key="hibernate.cache.use_second_level_cache">true</prop>
    <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.EhCacheProvider</prop>
    <prop key="hibernate.connection.provider_class">org.hibernate.connection.C3P0ConnectionProvider</prop>
    <prop key="hibernate.query.substitutions">true 1, false 0, yes 'Y', no 'N'</prop>
    <prop key="hibernate.bytecode.use_reflection_optimizer">true</prop>
    <prop key="hibernate.use_outer_join">true</prop>
    <prop key="hibernate.prepare_sql">true</prop>
    <prop key="hibernate.connection.release_mode">auto</prop>
    <prop key="hibernate.autoReconnect">true</prop>
    <prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
    <prop key="hibernate.query.factory_class">org.hibernate.hql.ast.ASTQueryTranslatorFactory</prop>
    </props>
    </property>
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean> <bean id="jdbcExceptionTranslator" class="org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator">
    <property name="dataSource"><ref bean="dataSource" /></property>
    </bean>
    <bean id="hibernateInterceptor" class="org.springframework.orm.hibernate3.HibernateInterceptor">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <!--baseTransactionProxy -->
    <bean id="baseTransactionProxy" abstract="true" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
    <property name="transactionManager"><ref bean="transactionManager" /></property>
    <property name="transactionAttributes">
    <props>
    <prop key="add*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="save*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="create*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="update*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="modify*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="get*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="find*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="remove*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="del*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="delete*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,-tion</prop>
    <prop key="*">PROPAGATION_REQUIRED,ISOLATION_DEFAULT,readOnly,-tion</prop>
    </props>
    </property>
    <property name="preInterceptors">
    <list><ref local="hibernateInterceptor"/></list>
    </property>
    <property name="postInterceptors">
    <list><ref local="hibernateInterceptor"/></list>
    </property>
    </bean>
    </beans>
      

  4.   

    <bean id="userAction" class="com.flash.card.action.UserAction" 
    scope="prototype"> 
    <property name="userService" ref="userService" /> 
    </bean> 
    改成
    <bean name="struts-config.xml中的path" class="com.flash.card.action.UserAction" 
    scope="prototype"> 
    <property name="userService" ref="userService" /> 
    </bean> 应该还有其他的配置问题