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;
}
}
随机推荐
- jquery 使用需要注意
jquery选择器,层选择器等多个选择器,jquery生成对象,jquery遍历对象, jquery ajax调用不要进行方法封装返回值方式调用,会取不到值. jquery使用要注意很多细节点才能将其 ...
- SPOJ HIGH Highways ——Matrix-Tree定理 高斯消元
[题目分析] Matrix-Tree定理+高斯消元 求矩阵行列式的值,就可以得到生成树的个数. 至于证明,可以去看Vflea King(炸树狂魔)的博客 [代码] #include <cmath ...
- 如何让win10实现关机确认-暂没确认
为了实现关机时有提示确认,防止不小心触碰后不提示就关机了.本人安装有360软件小助手,发生过此事多次. 1.网上找到 http://zhidao.baidu.com/link?url=dYB0fl2S ...
- iOS 设置1像素的UIView线
如果是代码实现,直接 在CGRectMake里把对应的参数设置为: 1.0/[UIScreenmainScreen].scale 即可. 如果是用xib实现,就需要将对应的限制拖一个I ...
- RecyclerView item 状态错乱
adapter中: private List<Integer> checkboxUserIdList = new ArrayList<>(); 在如下这个方法中: public ...
- Spark RDD 多文件输入
1.将多个文本文件读入一个RDD中 SparkConf conf=new SparkConf() .setMaster("local") .setAppName("sav ...
- java分享第九天-01(抽象类)
1 为什么需要抽象类?如何定义抽象类 是一种模板模式,抽象类为所有子类提供了一个通用模板,子类可以在这个模版基础上进行扩展: 通过抽象类,可以避免子类设计的随意性.通过抽象类,我们就可以做到严格限制子 ...
- Ubuntu14.04安装Ubuntu Tweak
第一步:添加tweak源 sudo add-apt-repository ppa:tualatrix/ppa 第二步:更新 sudo apt-get update 第三步:安装ubuntu-tweak ...
- PAT自测-5 Shuffling Machine
原题连接https://pta.patest.cn/pta/test/17/exam/4/question/264 Shuffling is a procedure used to randomize ...
- 使用TouchScript做2D按钮实现长按功能
导入TouchScript 下载地址:https://www.assetstore.unity3d.com/#/content/7394 把TouchScript和Touch Debugger两个预设 ...