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

解决方法1:指定execution
在执行目标方法之前指定execution
解决方法2:可能是execution写错了。请仔细检查。
其他——execution参数设置(带问好的可以不配置,否则必须配置):
execution(modifiers-pattern? ret-type-pattern declaring-type-pattern? name-pattern(param-pattern)throws-pattern?)
returning type pattern,name pattern, and parameters pattern是必须的.
modifiers-pattern:可以是public等。。
ret-type-pattern:返回值类型;可以为*表示任何返回值,全路径的类名等.
name-pattern()方法名和参数
throws-pattern异常。。。
例如:
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;
}
}
随机推荐
- UVA Live Achrive 4327 Parade (单调队列,dp)
容易想到dp[i][j]表示在第i行j个路口的开始走最大高兴值. 每次可以向左走,或者向右边走,然后向北走.(或者直接往北) 向左走到,状态转移为dp[i][j] = dp[i][k] + happy ...
- 索引属性 name指定
创建索引时的格式: db.collection.ensureIndex({param},{param}) 其中,第一个是索引的值,之前一直只用到了第一个,第二个参数便是索引的属性 比较重要的属性有: ...
- Python 之继承
概要 如果要修改现有类的行为,我们不必再从头建一个新的类,可以直接利用继承这一功能.下面将以实例相结合介绍继承的用法. 新建一个基类 代码如下: class Marvel(object): num ...
- Python实现进度条小程序
一.print()参数介绍 1.end:指定打印结束后添加的字符,默认值为换行符 for j in range(3): print('hello world') for i in range(3): ...
- Python实现购物小程序
一.需求 1.登录 { ‘xxx1’:{'passwd':'123','role':1,'moeny':10000,"carts":['mac']}, 'xxx1':{'passw ...
- MySQL详细安装过程
目录 一.概述 二.MySQL安装 三.安装成功验证 四.NavicatforMySQL下载及使用 一.概述 MySQL版本:5.7.17 下载地址:http://rj.baidu.com/soft/ ...
- vue axios请求频繁时取消上一次请求
一.前言 在项目中经常有一些场景会连续发送多个请求,而异步会导致最后得到的结果不是我们想要的,并且对性能也有非常大的影响.例如一个搜索框,每输入一个字符都要发送一次请求,但输入过快的时候其实前面的请求 ...
- tcl之list操作-lappend/lsearch/lsort/concat/split/join/
- tcl之基本语法—3
- Django基于Pycharm开发之三[LANGUAGE_CODE与TIME_ZONE]
在django/conf/global_settings.py 中,我们可以找到关于language和timezone的通用配置信息,源码如下: # Local time zone for this ...