spring注入与代理对象两个对象
[INFO ] 2015-05-18 15:44:37:124 [com.yjm.dao.CommonDAO] - CommonDAO...初始化... [INFO ] 2015-05-18 15:44:37:137 [com.yjm.service.FoodService] - FoodService...初始化...18794463 com.yjm.service.FoodService@11ec7df [INFO ] 2015-05-18 15:44:37:336 [com.yjm.service.FoodService] - FoodService...初始化...29516678 com.yjm.service.FoodService$$EnhancerByCGLIB$$5d6378b4@1c26386 [INFO ] 2015-05-18 15:44:37:349 [com.yjm.service.UserInfoService] - UserInfoService...初始化...648928 com.yjm.service.UserInfoService@9e6e0 [INFO ] 2015-05-18 15:44:37:360 [com.yjm.service.UserInfoService] - UserInfoService...初始化...6270370 com.yjm.service.UserInfoService$$EnhancerByCGLIB$$5fb685bb@5fada2 [INFO ] 2015-05-18 15:44:37:547 [com.yjm.ws.WebServiceImp] - WebServiceImp...初始化...2805666 [INFO ] 2015-05-18 15:44:37:627 [org.codehaus.xfire.spring.ServiceBean] - Exposing service with name {http://ws.namespace.com}ws [INFO ] 2015-05-18 15:44:37:634 [org.springframework.web.context.ContextLoader] - Root WebApplicationContext: initialization completed in 2615 ms
日志
构造方法里 输入
logger.info("FoodService...初始化..." + this.hashCode()+" "+this.toString());
配置
<?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:context="http://www.springframework.org/schema/context" xmlns:p="http://www.springframework.org/schema/p" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"> <!-- 初始化证书信息bean 存储pfx信息 单例 --> <bean id="initpfx" class="com.yjm.initcert.InitX509CertInfo" scope="singleton"></bean> <!-- 取得返回sessionFactory对象 --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"> </property> </bean> <!-- 取得 hibernate的sessionfactory 去封装spring自己的事务管理器 事务管理器比hibernate自带的强大很多 --> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <!-- 数据处理DAO类 sessionfactory工厂类 DAO sessionFactory单例处理 --> <bean id="commondao" class="com.yjm.dao.CommonDAO" scope="singleton"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <!-- 逻辑处理service类 Food--> <bean id="foodservice" class="com.yjm.service.FoodService" scope="singleton"> <property name="commonDAO" ref="commondao"></property> </bean> <!-- 逻辑处理service类 User--> <bean id="userservice" class="com.yjm.service.UserService" scope="singleton"> <property name="commonDAO" ref="commondao"></property> </bean> <!-- 逻辑处理service类 UserInfo--> <bean id="userinfoservice" class="com.yjm.service.UserInfoService" scope="singleton"> <property name="commonDAO" ref="commondao"></property> </bean> <!-- l --> <!-- 用代理类对 TransactionManager进行组合切面事务管理 --> <tx:advice id="advice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="find*" propagation="REQUIRED" read-only="true" /> <tx:method name="select*" propagation="REQUIRED" read-only="true" /> <tx:method name="load*" propagation="REQUIRED" read-only="true" /> <tx:method name="get*" propagation="REQUIRED" /> <tx:method name="save*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <!-- 定义切面 --> <aop:config> <aop:pointcut expression="execution(* com.yjm.service.*.*(..))" id="point" /> <aop:advisor advice-ref="advice" pointcut-ref="point" /> </aop:config> </beans>
service 层报错日志
java.lang.NullPointerException com.yjm.service.UserInfoService.verifyUserLoginInfo(UserInfoService.java:21) com.yjm.service.UserInfoService$$FastClassByCGLIB$$635690a4.invoke(<generated>) net.sf.cglib.proxy.MethodProxy.invoke(MethodProxy.java:191)
可见是代理对象在处理业务,而不是spring 注入的bean再处理业务。
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。