<bean id="dataSource" 
class="org.apache.commons.dbcp.BasicDataSource"> 
<property name="driverClassName"> 
<value>com.mysql.jdbc.Driver</value> 
</property> 
<property name="url"> 
<value>jdbc:mysql://localhost:3306/test</value> 
</property> 
<property name="username"> 
<value>root</value> 
</property> 
<property name="password"> 
<value>1234</value> 
</property> 
</bean> <!--LocalSessionFactoryBean 整合hibernate3时的类 -->
<bean id="sessionFactory" 
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean" 
destroy-method="close"> 
<property name="dataSource"> 
<ref bean="dataSource"/> 
</property>加载sessionFactory会出错,这些就出现Servlet action is not available异常,去掉这些sessionFactory就可正常调用与struts整合, 如果控制台sessionFactory不会出错

解决方案 »

  1.   

    public static void main(String args[]){
      

  2.   

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <beans>
    <!--hibernate property Configure -->
    <bean id="propertyConfigure"
    class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="location">
    <value>WebRoot/WEB-INF/configure/hibernate.properties</value>
    </property>
    </bean> <!-- dataSource Configure-->
    <bean id="dataSource"
    class="org.apache.commons.dbcp.BasicDataSource">
    <property name="driverClassName">
    <value>${hibernate.connection.driver_class}</value>
    </property>
    <property name="url">
    <value>${hibernate.connection.url}</value>
    </property>
    <property name="username">
    <value>${hibernate.connection.username}</value>
    </property>
    <property name="password">
    <value>${hibernate.connection.password}</value>
    </property>
    </bean> <!-- SessionFactory Configure -->
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"
    destroy-method="destroy">
    <property name="dataSource">
    <ref local="dataSource" />
    </property>
    <property name="hibernateProperties">
    <props>
    <prop key="hibernate.dialect">
    ${hibernate.dialect}
    </prop>
    <prop key="hibernate.show_sql">
    ${hibernate.show_sql}
    </prop>
    </props>
    </property>
    <property name="mappingDirectoryLocations">
    <list>
    <value>classpath:com/wang/demo/hibernate/hbm/</value>
    </list>
    </property>
    </bean> <!-- DAO Configure -->
    <bean id="springDAO" class="com.wang.demo.dao.impl.SpringDAO">
    <property name="sessionFactory">
    <ref local="sessionFactory" />
    </property>
    </bean> <!-- ServiceTaget Configure -->
    <bean id="springServiceTaget"
    class="com.wang.demo.service.impl.SpringService">
    <property name="springDAO">
    <ref local="springDAO" />
    </property>
    </bean> <!-- Service Configure -->
    <bean id="springService"
    class="org.springframework.aop.framework.ProxyFactoryBean">
    <property name="proxyInterfaces">
    <value>com.wang.demo.service.ISpringService</value>
    </property>
    <property name="interceptorNames">
    <value>springServiceTaget</value>
    </property>
    </bean>
    </beans>