@Servicepublic class ScormDataHelper implements ScormDataTransferred{
@Autowired
private lesson_locationDAO objlesson_locationDAO ;上面的dao中已经加上了repository注解
不知道为什么在调用dao中的方法是报空指针异常? 会有哪几种可能的原因?
@Autowired
private lesson_locationDAO objlesson_locationDAO ;上面的dao中已经加上了repository注解
不知道为什么在调用dao中的方法是报空指针异常? 会有哪几种可能的原因?
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context" 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/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/jee
http://www.springframework.org/schema/jee/spring-jee-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="byName" default-lazy-init="false"> <!-- 定义受环境影响易变的变量 -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<!-- 标准配置 -->
<value>classpath:jdbc.properties</value>
</list>
</property>
</bean>
<!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->
<context:component-scan base-package="com.ulearning.ulms" />
<!-- <context:annotation-config /> -->
<!-- 数据源配置,使用应用内的DBCP数据库连接池 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
<!-- Connection Info -->
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" /> <!-- Connection Pooling Info -->
<property name="initialSize" value="5" />
<property name="maxActive" value="100" />
<property name="maxIdle" value="30" />
<property name="maxWait" value="500" />
<property name="defaultAutoCommit" value="false" />
</bean> <!-- Hibernate配置 -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
<prop key="hibernate.connection.release_mode">${hibernate.connection.release_mode}</prop>
</props>
</property>
<property name="packagesToScan" value="com.ulearning.ulms." />
</bean>
<!--
<bean id="datesource"
class="org.apache.commons.dbcp.BasicDataSource">
<property name="driverClassName"
value="oracle.jdbc.driver.OracleDriver">
</property>
<property name="url"
value="jdbc:oracle:thin:@192.168.0.209:1521:orcl">
</property>
<property name="username" value="ulms_bankedu"></property>
<property name="password" value="ulms_bankedu"></property>
</bean>
<bean id="SessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="datesource" />
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
org.hibernate.dialect.Oracle9Dialect
</prop>
</props>
</property>
<property name="configLocation"
value="hibernate.cfg.xml">
</property>
</bean>
--> <!-- 事务管理器配置,单数据源事务 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean> <!-- 使用annotation定义事务 -->
<!--
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
-->
<aop:config proxy-target-class="true">
<aop:advisor pointcut="execution(* com.ulearning.ulms..*.*Manager.*(..))" advice-ref="txAdvice" />
<aop:advisor pointcut="execution(* com.ulearning.ulms..*.*Dao.*(..))" advice-ref="txAdvice" />
</aop:config> <tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="get*" read-only="true" />
<tx:method name="find*" read-only="true" />
<tx:method name="query*" read-only="true" />
<tx:method name="is*" read-only="true" />
<tx:method name="*" />
</tx:attributes>
</tx:advice>
</beans>