云笔涛墨 2015-06-09 09:36 采纳率: 100%
浏览 1143

SpringAOP用注解开发操作日志,求大神指导。急!QQ794124093

我用SSM框架,写这个日志,总是切不进去,也不知道是什么原因,找不到错误,
个人猜测是不是配置文件扫描类有问题。项目能正常运行,增删改查都没问题,就这个AOP搞不定,就知道帮忙谢谢。

@Aspect
@Component
public class OperateLogHandler {
@Resource
private OperateLogService operateLogService;// 操作日志Service

/**
 * 添加业务逻辑方法切入点
 */
@Pointcut("execution(* com.szkingdom.cdpf.admin.service.impl.*.save*(..))")
public void saveServiceCall() {
}

/**
 * 修改业务逻辑方法切入点
 */
@Pointcut("execution(* com.szkingdom.cdpf.admin.service..*.update*(..))")
public void updateServiceCall() {
}

/**
 * 删除业务逻辑方法切入点
 */
@Pointcut("execution(* com.szkingdom.cdpf.admin.service..*.delete*(..))")
public void deleteServiceCall() {
}

/**
 * 操作员添加操作日志(后置通知)
 */
@Before(value="saveServiceCall()")
public void saveServiceCallCalls(JoinPoint joinPoint) throws Throwable{
    System.out.println("出现吧,出现把,出现把");

web.xml是这样的
 <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/applicationContext*.xml</param-value>


<!-- 配置监听器 -->

org.springframework.web.context.ContextLoaderListener


com.szkingdom.cdpf.web.listener.ServerStartupListener

<!-- 字符编码过滤器 -->

encoding
org.springframework.web.filter.CharacterEncodingFilter

encoding
UTF-8


forceEncoding
true



encoding
*.do

<!-- 配置框架前端控制器 -->

springmvc
org.springframework.web.servlet.DispatcherServlet

contextConfigLocation
classpath:springmvc/springmvc-servlet.xml

1


springmvc
*.do

springmvc-servlet.xml文件是这样的
    <!-- 启用注解功能 -->
<context:annotation-config />
<context:component-scan base-package="com.szkingdom.cdpf.*" />
<mvc:annotation-driven /> 
    略。。

    applicationContext.xml文件是这样的
        <!-- 启用AOP功能 -->
<aop:aspectj-autoproxy/>
略
。。。。
    <!-- TransactionManager -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="dataSource"></property>
</bean>
<!-- 事务通知Advice。Aspect是横切面,抽象的,Advice是具体存在的Aspect
AOP功能增强器
 -->
<tx:advice id="transactionAdvice"  transaction-manager="transactionManager">
    <tx:attributes>
        <tx:method name="insert*" propagation="REQUIRED" isolation="DEFAULT" rollback-for="java.lang.Exception"/>
        <tx:method name="delete*" propagation="REQUIRED" isolation="DEFAULT" rollback-for="java.lang.Exception"/>
        <tx:method name="update*" propagation="REQUIRED" isolation="DEFAULT" rollback-for="java.lang.Exception"/>
        <tx:method name="select*"  read-only="true"/>
        <tx:method name="*" propagation="REQUIRED" isolation="DEFAULT" rollback-for="java.lang.Exception"/>
    </tx:attributes>
</tx:advice>    
<!-- 切入 -->
<aop:config>
    <aop:advisor advice-ref="transactionAdvice" pointcut="execution(* com.szkingdom.cdpf.admin.service..*.*(..))"/>
</aop:config>
    我这事务感觉不太对,先不管,
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 (希望可以解决问题)ma和mb文件无法正常打开,打开后是空白,但是有正常内存占用,但可以在打开Maya应用程序后打开场景ma和mb格式。
    • ¥20 ML307A在使用AT命令连接EMQX平台的MQTT时被拒绝
    • ¥20 腾讯企业邮箱邮件可以恢复么
    • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
    • ¥15 错误 LNK2001 无法解析的外部符号
    • ¥50 安装pyaudiokits失败
    • ¥15 计组这些题应该咋做呀
    • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
    • ¥15 让node服务器有自动加载文件的功能
    • ¥15 jmeter脚本回放有的是对的有的是错的