解决方案 »

  1.   

    自己定下 ,在Action中调用的时候loginBo为空,后台没有报错,自己搭的框架玩,没看出来时哪出错了
    @Autowired
    public LoginBo loginBo;详细的application配置文件<?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"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:dwr="http://www.directwebremoting.org/schema/spring-dwr"
    xsi:schemaLocation="http://www.springframework.org/schema/beans   
        http://www.springframework.org/schema/beans/spring-beans-3.2.xsd  
        http://www.springframework.org/schema/context   
        http://www.springframework.org/schema/context/spring-context-3.2.xsd  
        http://www.springframework.org/schema/aop  
        http://www.springframework.org/schema/aop/spring-aop-3.2.xsd  
        http://www.springframework.org/schema/tx  
        http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
    <!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->
    <context:component-scan base-package="com.bo,com.dao" />
    <!-- 事务管理器配置,单数据源事务 -->
    <bean id="transactionManager"
    class="org.springframework.orm.hibernate4.HibernateTransactionManager">
    <property name="sessionFactory" ref="sessionFactory" />
    </bean>
    <!-- 使用annotation定义事务 -->
    <tx:annotation-driven transaction-manager="transactionManager"
    proxy-target-class="true" />
    <!-- 设置事务工厂 -->
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    <property name="dataSource">
    <ref bean="dataSource" />
    </property>
    <property name="namingStrategy">
    <bean class="org.hibernate.cfg.ImprovedNamingStrategy" />
    </property>
    <property name="hibernateProperties">
    <props>
    <!-- 命名规则 My_NAME->MyName -->
    <prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
    <prop key="hibernate.dialect">${hibernate.dialect}</prop>
    <prop key="hibernate.max_fetch_depth">3</prop>
    <!--prop key="hibernate.hbm2ddl.auto">update</prop-->
    <prop key="hibernate.jdbc.fetch_size">18</prop>
    <prop key="hibernate.jdbc.batch_size">10</prop>
    <prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
    <prop key="hibernate.format_sql">${hibernate.format_sql}</prop>
    <!-- jsr303验证模式 因为其要么验证 要么不验证 不能按照规则走 所以此处禁用 -->
                    <!-- #http://docs.jboss.org/hibernate/entitymanager/3.6/reference/en/html/configuration.html -->
    <prop key="javax.persistence.validation.mode">none</prop>
    <!-- 只扫描class文件,不扫描hbm,默认两个都搜索 -->
                    <prop key="hibernate.archive.autodetection">class</prop>
                    <!-- 不检查@NamedQuery -->
                    <prop key="hibernate.query.startup_check">false</prop>
                    <!-- 禁用二级缓存 -->
                    <!--prop key="hibernate.cache.use_second_level_cache">false</prop>
                    <prop key="hibernate.cache.use_query_cache">false</prop-->
                    <!-- 使用 memcached -->
                    <!-- 设置缓存类 
                    <prop key="hibernate.cache.region.factory_class">com.ces.xarch.plugins.memcache.MemcacheRegionFactory</prop>
                    <prop key="hibernate.cache.provider_class">com.googlecode.hibernate.memcached.MemcachedCacheProvider</prop>-->
                    <!--prop key="hibernate.memcached.memcacheClientFactory">com.googlecode.hibernate.memcached.dangamemcached.DangaMemcacheClientFactory</prop-->
                    <!-- 设置memcache缓存服务器端口
                    <prop key="hibernate.memcached.servers">192.168.40.128:11211</prop> --> 
                    <!-- 设置二级缓存的前缀名称
    <prop key="hibernate.cache.region_prefix">quality.cache.ehcache</prop> -->  
                    <!-- 是否缓存查询结果
                    <prop key="hibernate.cache.use_query_cache">true</prop> -->
                    <!-- 开启二级缓存 
                    <prop key="hibernate.cache.use_second_level_cache">true</prop>-->
                    <!-- 否使用结构化的方式缓存对象  
    <prop key="hibernate.cache.use_structured_entries">true</prop>-->
    </props>
    </property>
    </bean>
    <!-- 定义受环境影响易变的变量 -->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
    <property name="systemPropertiesModeName" value="SYSTEM_PROPERTIES_MODE_OVERRIDE" />
    <property name="ignoreResourceNotFound" value="true" />
    <property name="locations">
    <list>
    <!-- 标准配置 -->
    <value>/WEB-INF/classes/db_config.properties</value>
    </list>
    </property>
    </bean>
    <!-- 数据源配置,使用应用内的DBCP数据库连接池 -->
    <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
    destroy-method="close">
    <!-- Connection Info -->
    <property name="driverClassName" value="${hibernate.connection.driver_class}" />
    <property name="url" value="${hibernate.connection.url}" />
    <property name="username" value="${hibernate.connection.username}" />
    <property name="password" value="${hibernate.connection.password}" />

    <!-- Connection Pooling Info -->
    <property name="initialSize" value="10" />
    <property name="maxActive" value="10" />
    <property name="maxIdle" value="10" />
    <property name="defaultAutoCommit" value="false" />
    </bean>
    </beans>  
      

  2.   

    为何不见你的SessionFactory 这个也需要注入。
      

  3.   

    注入了 在DAO层中注入的@Autowired 
    public void setSessionFactoryOverride(SessionFactory sessionFactory) {
    super.setSessionFactory(sessionFactory);
    }这个不注入会报错,现在就是没报错 但是service就是没注入进去
      

  4.   

    Spring的基础jar 应该不是少jar吧
      

  5.   


    文件夹里面是基础的jar  jar应该是全的
      

  6.   

    commons-logging-1.1.1  jar
    spring-context-support-3.0.4.RELEASE  jar
      

  7.   

    这两个jar有的

    既然用的注解,那把<bean id="sessionFactory"
            class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
    改成这样:
    <bean id="sessionFactory"
    class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
      

  8.   

    用的hibernate4  之前在网上查过 hibernate4里面不用没有AnnotationSessionFactoryBean这个的,用的是我现在的配置
      

  9.   

    还是少了jar包,struts-spring-plugin~~!