Pointcut is malformed: Pointcut is not well-formed: expecting 'identifier' at character position 0 ^
错误提示:

解决方法:指定execution
在执行目标方法之前指定execution
例如:
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component;
//把这个类声明为一个切面,需要把该类放入到IOC容器中
@Aspect
@Component
public class LoggingAspect {
//声明该方法是一个前置通知:在目标方法之前执行
@Before("execution(public int lixiuming.spring.aop.impl.ArithmeticCaculator.add(int, int) )")
public void beforeMethod(){
System.out.println("the method begins with");
}
}
接口:
import org.springframework.stereotype.Service;
@Service
public interface ArithmeticCaculator {
int add(int i,int j);
int sub(int i,int j);
int mul(int i,int j);
int div(int i,int j);
}
测试方法:
public class Main {
public static void main(String[] args) {
ApplicationContext cxt = new ClassPathXmlApplicationContext("ApplicationContext.xml");
ArithmeticCaculator arithmeticCaculator = cxt.getBean(ArithmeticCaculator.class);
int result = arithmeticCaculator.add(3, 6);
System.out.println("result:"+result);
}
}
实现方法:
import org.springframework.stereotype.Component;
@Component
public class ArithmeticCaculatorImpl2 implements ArithmeticCaculator {
@Override
public int add(int i, int j) {
int result = i+j;
return result;
}
@Override
public int sub(int i, int j) {
int result = i-j;
return result;
}
@Override
public int mul(int i, int j) {
int result = i*j;
return result;
}
@Override
public int div(int i, int j) {
int result = i/j;
return result;
}
}
随机推荐
- a pity
机会只眷顾有准备且自信的人,此生谨记. ——Charles Hsu 2014-09-04
- iOS 隐藏键盘的几种常见方法
1.设置return key,然后为Did End On Exit事件添加响应方法,并在方法内添加代码:[self.textfieldName resignFirstResponder]. 2.将背景 ...
- 浅谈JAVA设计模式
没有万行的代码量,就不要想搞清楚设计模式.目前本人代码量大约在六千五百行,2016年需要继续努力,尽快完成万行之约. 工作之余需要,下面提前简单讨论一下设计模式. 创建型模式,共五种:工厂模式.抽象工 ...
- 【原】iOS学习之UIApplication及其代理
1. 什么是UIApplication UIApplication 对象是应用程序的象征,不能手动创建,不能 alloc init,一个应用程序只允许 一个 . 每个应用都有自己的 UIApplica ...
- 用介个新的blog咯..
之前csdn实在是太卡了.. 只要一写比较长的blog就卡的要死.. 转过来这吧,比较好吧.. 原blog地址 啊为啥域名叫darklove呢.. 这是很久之前创建的.. 简单来说是一个和clearl ...
- VS2010 OpenCV 2.4.6 配置 (Win7 32位)
1.下载安装OpenCV 下载OpenCV-2.4.6.0 (文件大小 291M),下载地址如下,下载完成后解压缩到路径%OpenCV%下,本文%OpenCV%=E:\图像处理与计算机视觉. http ...
- AJAX实现跨域的三种方法
由于在工作中需要使用AJAX请求其他域名下的请求,但是会出现拒绝访问的情况,这是因为基于安全的考虑,AJAX只能访问本地的资源,而不能跨域访问. 比如说你的网站域名是aaa.com,想要通过AJAX请 ...
- java 打印流(PrintStream)
打印流(PrintStream):打印流可以打印任意类型的数据,而且打印流在打印数据之前会将数据转为字符串在进行打印 PrintStream可以接受文件和其他字节输出流,所以打印流是对普通字节输出流的 ...
- python UnicodeDecodeError: 'ascii' codec can't decode byte 0xa6 in position 907: ordinal not in range(128)
import sysreload(sys)sys.setdefaultencoding('utf-8')
- YUV与像素值之间的关系
一幅彩色图像的基本要素是什么? 说白了,一幅图像包括的基本东西就是二进制数据,其容量大小实质即为二进制数据的多少.一幅1920x1080像素的YUV422的图像,大小是1920X1080X2=4147 ...