springboot1.5.9集成shiro成功 之后加入aop就报错

springboot1.5.9集成shiro成功 之后加入aop就报错,第1张

我用springboot的和shiro的时候也有问题,不过不是aop,是没被shiro控制的接口会提示404,所以放弃了shiro,转为用spring security,其实差不多的

有配置的,代码示例如下:

这是业务测试类:

package aop.annotation.service

import org.springframework.context.annotation.Scope

import org.springframework.stereotype.Service

@Service("deptSerivceImpl")

@Scope("prototype")

public class DeptSerivceImpl implements DeptService {

public DeptSerivceImpl(){}

public void delete() {

try {

Thread.sleep(200)

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace()

}

System.out.println("删除部门")

}

public void save() {

try {

Thread.sleep(500)

} catch (InterruptedException e) {

// TODO Auto-generated catch block

e.printStackTrace()

}

System.out.println("保存部门")

}

}

这个是切面测试类:

package aop.annotation.aspect

import org.aspectj.lang.ProceedingJoinPoint

import org.aspectj.lang.annotation.Around

import org.aspectj.lang.annotation.Aspect

import org.aspectj.lang.annotation.Before

import org.aspectj.lang.annotation.Pointcut

import org.springframework.stereotype.Component

import org.springframework.util.StopWatch

@Aspect

@Component("timeHander")

public class TimeHander {

@Pointcut("bean (*Service)")

public void myPointCut(){}

@Before("maPointCut()")

public void myBefore(){

System.out.println("-----执行前置处理-------")

}

@Around("myPointCut()")

public Object handerTime(ProceedingJoinPoint pjp){

try {

// 开始计时

StopWatch watch=new StopWatch(pjp.getTarget().getClass().getName())

watch.start(pjp.getSignature().getName())

Object obj=pjp.proceed()

// 停止计时

watch.stop()

System.out.println(watch.prettyPrint())

return obj

} catch (Throwable e) {

// TODO Auto-generated catch block

e.printStackTrace()

return null

}//执行目标

}

}

找找这个原因

“Caused by: java.lang.IllegalArgumentException: error at ::0 can't find referenced pointcut anyMethod”

然后再看看

Error creating bean with name 'personService' defined in class path resource [bean.xml],personService

有没有创建正确,拼写对不对


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11686990.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-17
下一篇 2023-05-17

发表评论

登录后才能评论

评论列表(0条)

保存