struts1 spring2.5 hibernate3 aop 切不进去啊 junit 好用 一到 web 就不好用

jfheng 2013-03-14 08:11:49
怀疑 项目太大 东西 太多了
再就是
跟这个代理 是不是有关系
<bean id="dealHandleMgrProxy" name="dealHandleMgrProxy" parent="baseTransactionProxy">
...全文
154 19 打赏 收藏 转发到动态 举报
写回复
用AI写文章
19 条回复
切换为时间正序
请发表友善的回复…
发表回复
jfheng 2013-03-15
  • 打赏
  • 举报
回复
struts-config.xml 中加载 spring 配置文件 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property="contextConfigLocation" value="classpath:\GlobalOdocSpringContext.xml" /> </plug-in> GlobalOdocSpringContext.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: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/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd"> <!--开发平台配置--> <import resource="classpath:rmi-hyhrm-springContext.xml"/> <import resource="classpath:Jspm-springContext.xml"/> <import resource="classpath:JobTask-springContext.xml"/> <!-- <import resource="classpath:GlobalOnlineSpringContext.xml"/> --> <import resource="classpath:Aop-odoc-springContext.xml"/> <import resource="classpath:syhy/modules/office/deal/dealdoc/fenfa/modules-fenfa-springContext.xml"/> <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource" scope="singleton"> <property name="basenames"> <set> <value>classpath:applicationConfig</value> <value>messages</value> </set> </property> </bean> <bean id="propertyHolderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations"> <list> <value>classpath:hibernate.properties</value> <value>classpath:systemconfig.properties</value> </list> </property> </bean> <!-- com.mchange.v2.c3p0.ComboPooledDataSource --> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"> <property name="driverClass"> <value>${hibernate.connection.driver_class}</value> </property> <property name="jdbcUrl"> <value>${hibernate.connection.url}</value> </property> <property name="user"> <value>${hibernate.connection.username}</value> </property> <property name="password"> <value>${hibernate.connection.password}</value> </property> <property name="minPoolSize"><value>${hibernate.c3p0.min_size}</value></property> <property name="maxPoolSize"><value>${hibernate.c3p0.max_size}</value></property> <property name="maxIdleTime"><value>1800</value></property> <property name="checkoutTimeout"><value>${hibernate.c3p0.timeout}</value></property> <property name="acquireIncrement"><value>${hibernate.c3p0.acquire_increment}</value></property> <property name="maxStatements"><value>${hibernate.c3p0.max_statements}</value></property> <property name="initialPoolSize"><value>10</value></property> <property name="idleConnectionTestPeriod"><value>1800</value></property> <property name="acquireRetryAttempts"><value>30</value></property> <property name="breakAfterAcquireFailure"><value>false</value></property> <property name="testConnectionOnCheckout"><value>false</value></property> </bean> <!-- <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close"> <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> --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="mappingResources"> <list> <!--fenfa--> <value>syhy/modules/commons/fenfa/persistence/Fenfa.hbm.xml</value> <!--fileupload--> <value>syhy/modules/commons/fileupload/filesystem/DiskTempFile.hbm.xml</value> <value>syhy/modules/commons/fileupload/hibernate/ByteArrayTempFile.hbm.xml</value> <value>syhy/modules/commons/fileupload/hibernate/QueryByteArrayTempFile.hbm.xml</value> <!--odoc-handle--> <value>syhy/modules/office/deal/dealdoc/handle/persistence/doc/DocOfficial.hbm.xml</value> <value>syhy/modules/office/deal/dealdoc/handle/persistence/doc/Content.hbm.xml</value> <value>syhy/modules/office/deal/dealdoc/handle/persistence/DealHandle.hbm.xml</value> <value>syhy/modules/office/deal/dealdoc/handle/persistence/DealInfo.hbm.xml</value> <value>syhy/modules/office/deal/dealdoc/handle/persistence/FileAttachHandle.hbm.xml</value> <value>syhy/modules/office/deal/dealdoc/handle/persistence/IntegrateIdea.hbm.xml</value> <value>syhy/modules/office/deal/dealdoc/handle/persistence/LeaderIdea.hbm.xml</value> </list> </property> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">${hibernate.dialect}</prop> <prop key="hibernate.show_sql">${hibernate.show_sql}</prop> <prop key="hibernate.cache.use_query_cache">${hibernate.cache.use_query_cache}</prop> <prop key="hibernate.cache.provider_class">${hibernate.cache.provider_class}</prop> <prop key="hibernate.auto-import">false</prop> <!-- <prop key="hibernate.c3p0.max_size">${hibernate.c3p0.max_size}</prop> <prop key="hibernate.c3p0.min_size">${hibernate.c3p0.min_size}</prop> <prop key="hibernate.c3p0.timeout">${hibernate.c3p0.timeout}</prop> <prop key="hibernate.c3p0.max_statements">${hibernate.c3p0.max_statements}</prop> <prop key="hibernate.c3p0.idle_test_period">${hibernate.c3p0.idle_test_period}</prop> <prop key="hibernate.c3p0.acquire_increment">${hibernate.c3p0.acquire_increment}</prop> <prop key="hibernate.c3p0.validate">${hibernate.c3p0.validate}</prop> --> </props> </property> <property name="dataSource"> <ref local="dataSource"/> </property> <property name="lobHandler"> <ref local="defaultLobHandler"/> </property> </bean> <bean id="defaultLobHandler" name="defaultLobHandler" class="org.springframework.jdbc.support.lob.DefaultLobHandler"/> <!--<bean id="nativeJdbcExtractor" class="org.springframework.jdbc.support.nativejdbc.CommonsDbcpNativeJdbcExtractor" lazy-init="false"/> <bean id="defaultLobHandler" name="defaultLobHandler" class="org.springframework.jdbc.support.lob.OracleLobHandler"> <property name="nativeJdbcExtractor"> <ref local="nativeJdbcExtractor"/> </property> </bean>--> <bean id="jdbcOperations" class="org.springframework.jdbc.core.JdbcTemplate"> <constructor-arg> <ref local="dataSource"/> </constructor-arg> </bean> <bean id="hibernateOperations" class="org.springframework.orm.hibernate3.HibernateTemplate"> <constructor-arg> <ref local="sessionFactory"/> </constructor-arg> <property name="allowCreate"> <value>true</value> </property> </bean> <bean id="hibernateOperationsEhcache" class="org.springframework.orm.hibernate3.HibernateTemplate"> <constructor-arg> <ref local="sessionFactory"/> </constructor-arg> <property name="allowCreate"> <value>true</value> </property> <property name="cacheQueries"> <value>true</value> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory"> <ref local="sessionFactory"/> </property> </bean> <bean id="baseTransactionProxy" name="baseTransactionProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" abstract="true"> <property name="transactionManager"> <ref bean="transactionManager"/> </property> <property name="transactionAttributes"> <props> <prop key="upload*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="get*">PROPAGATION_REQUIRED,readOnly</prop> <prop key="delete*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="find*">PROPAGATION_REQUIRED</prop> <prop key="clear*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="save*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="add*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="update*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="create*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="send*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="copy*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="end*">PROPAGATION_REQUIRED,-Exception</prop> <prop key="count*">PROPAGATION_REQUIRED</prop> <prop key="verify*">PROPAGATION_REQUIRED</prop> </props> </property> </bean> <bean id="persistOperations" class="syhy.modules.commons.persistence.impl.PersistOperations"> <constructor-arg> <ref bean="hibernateOperations"/> </constructor-arg> </bean> <bean id="persistOperationsEhcache" class="syhy.modules.commons.persistence.impl.PersistOperations"> <constructor-arg> <ref bean="hibernateOperationsEhcache"/> </constructor-arg> </bean> </beans>
jfheng 2013-03-15
  • 打赏
  • 举报
回复
我想问一下 你们在 web 应用中 真正用过吗 , junit 中同样的配置 方法 是好用的 一到 web 就不好使
  • 打赏
  • 举报
回复
http://ch-space.iteye.com/blog/493956 好好看看人家写的。
jfheng 2013-03-15
  • 打赏
  • 举报
回复
junit 中同样的配置 方法 是好用的 一到 web 就不好使
尹剑 2013-03-15
  • 打赏
  • 举报
回复
你的那个Aspect(即切面提供商)配置错了吧?<aop:aspect id="afterFenfa" ref="fenfaHandleMgrProxy">,其中fenfaHandleMgrProxy配置到bean里面了吗? 如果配置了的话,再看pointcut对了没?execution(访问权限(可不写),包名.方法名(参数)), 一层层的往下看,是否对了? 实在搞不定,你就用注解方式来配置,并且在Spring3.0之后的官方文档里面配置AOP时 也推荐用注解方式 首先第一步写切面提供商 如 @Aspect public class ServiceAOP { public static final String EDP = "execution(* com.stee.vmsManagement..*Service*.*(..))"; @Before(EDP) public void testAOP() { System.out.println("execute before aop...."); } } 第二步:ServiceAOP配置到Spring中,或者加一个@Component(bean的名字) 第三步:在Spring的配置文件中配置<context:annotation-config />就好了
悲催的程序猿 2013-03-15
  • 打赏
  • 举报
回复
引用 6 楼 fangmingshijie 的回复:
什么错都不说,没有问到点子上
+1
  • 打赏
  • 举报
回复
什么错都不说,没有问到点子上
jfheng 2013-03-15
  • 打赏
  • 举报
回复
没人知道啊
jfheng 2013-03-15
  • 打赏
  • 举报
回复
struts-config.xml 中加载 spring 配置文件 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property="contextConfigLocation" value="classpath:\GlobalOdocSpringContext.xml" /> </plug-in> 差了一天资料 怀疑 这样整合sturts1 和 spring 后,aop不能发挥作用,
jfheng 2013-03-15
  • 打赏
  • 举报
回复
看来 可以离开了 失望啊
jfheng 2013-03-15
  • 打赏
  • 举报
回复
文件全称 applicationConfig.properties 配置只需要 applicationConfig
  • 打赏
  • 举报
回复
applicationConfig没有后缀啥的?
jfheng 2013-03-15
  • 打赏
  • 举报
回复
<value>classpath:applicationConfig</value> 配置属性文件 的文件名 "classpath:\GlobalOdocSpringContext.xml"去掉\ 跟他没关系
  • 打赏
  • 举报
回复
"classpath:\GlobalOdocSpringContext.xml"去掉\ <value>classpath:applicationConfig</value> 这个是什么意思?
jfheng 2013-03-15
  • 打赏
  • 举报
回复
没人知道吗
jfheng 2013-03-14
  • 打赏
  • 举报
回复
原来 就没有 public 也不好使
  • 打赏
  • 举报
回复
expression="execution(public* syhy.modules.office.deal.dealdoc.handle.bslogin.DealBaseMgr.sendDealBanliToBanj*(..))" 目测是这表达式错了,改为: expression="execution(* syhy.module.*.*(..))"
jfheng 2013-03-14
  • 打赏
  • 举报
回复
<aop:config> <aop:aspect id="afterFenfa" ref="fenfaHandleMgrProxy"> <aop:pointcut id="pointcutFenfa" expression="execution(public* syhy.modules.office.deal.dealdoc.handle.bslogin.DealBaseMgr.sendDealBanliToBanj*(..))"/> <aop:after-returning pointcut-ref="pointcutFenfa" method="addFenfaAop" returning="retVal" /> </aop:aspect> </aop:config>
  • 打赏
  • 举报
回复
配置文件看看先,什么叫切不进去

67,513

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧