下文略啰嗦,直接讲重点:
aop只能适用于 protect 和public 修饰符修饰的方法
我们使用的Springboot版本号是1.5.9.RELEASE,因为同事写代码不规范导致的BUG
因为系统新的需求,所以需要做AOP日志啥也不说,一顿疯狂的引入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j</artifactId>
<version>1.3.8.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.0.0</version>
</dependency>
额。。。倒数第二个就是AOP的引用,然后一顿疯狂的切面,大致代码就如下,其他业务代码就不贴了,反正就是切了
@Pointcut("execution(public * net.wdm.jeeshopmanage.controller..*.*(..))")
public void webLog() {
}
然后就是各种注入失败,各种空指针,传说中价值几百万的错误 NullPointerException,非常郁闷,各种检查,各种查询,最后发现大神写的博客
大神博客写到,aop只能适用于 protect 和public 修饰符修饰的方法,因为个人习惯的原因,我的对外的所有controller都是public 的,所以理论上讲,是不会存在这个问题的
但是
防火防盗防同事,嗯,就是这样,部分代码如下
@RequestMapping(value = "/selectList", method = RequestMethod.POST)
private String selectList(String billNo, HttpServletRequest request) {
//。。。。。
}
@RequestMapping(value = "/selectStatusN", method = RequestMethod.POST)
private String selectStatusN(String billno, HttpSession session) {
//。。。。。
}
抱着试一试的心态,改成了public,然后,然后就好了,这特么,记一笔。