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;
}
}
随机推荐
- matlab一次读取多张图片
实验平台:matlab R2010Rb 读取C:\Users\KCl\Documents\MATLAB\SRCNN\Set5文件夹下所有bmp文件,并存储到im字典中 clear all clc im ...
- C#的接口基础教程之五 实现接口
1.显式实现接口成员 为了实现接口,类可以定义显式接口成员执行体(Explicit interface member implementations).显式接口成员执行体可以是一个方法.一个属性.一个 ...
- 操作系统(5)_内存管理_李善平ppt
i386先通过段是管理,在通过页是管理
- 算法竞赛入门经典5.1 从c到c++
这个章节主要是讲述了一些c++的特性,在这里面,对我用处最大的应该就是字符串吧.首先是getline,getchar,stringstream的使用了吧. 首先介绍这三个函数. 1. getline函 ...
- Linux下重要日志及查看方式
1.Linux下重要日志文件介绍 /var/log/boot.log 该文件记录了系统在引导过程中发生的事件,就是Linux系统开机自检过程显示的信息,如图1所示: 图1 /var/log/boot. ...
- mui的选项卡js选中指定项
dom结构:在一定条件下想默认选中第二个选项卡 <div id="segmentedControl" class="mui-segmented-control mu ...
- Java开发学生管理系统
Java 学生管理系统 使用JDBC了链接本地MySQL 数据库,因此在没有建立好数据库的情况下没法成功运行 (数据库部分, Java界面部分, JDBC部分) 资源下载: http://downlo ...
- 关于debug
2019-04-05 11:18:15 1. debug 需巧用两个工具 1.1 用‘#’把感觉会出错的代码段注释掉 多行注释有两种快捷操作: 在需要注释的多行代码块前后加一组三引号''' 选中代 ...
- 虚拟机中配置SQL SERVER2008R2远程访问
VM虚拟机中配置数据库访问 选择虚拟机设置--硬件--网络适配器,选择桥接模式:直接连接物理网络 不可选用主机模式(与主机共享专用网络) 数据库远程配置,转自:http://jingyan.baidu ...
- 1022 D进制的A+B (20)(20 分)
1022 D进制的A+B (20)(20 分) 输入两个非负10进制整数A和B(<=\(2^{30}-1\)),输出A+B的D (1 < D <= 10)进制数. 输入格式: 输入在 ...