问题描述最近在做一个springboot的项目中使用aop做全局日志管理但是出现了这样的问题controller包下的类都正常的切到了,但是service层怎么也没反应问题出现的环境背景及自己尝试过哪些方法@EnableAspectJAutoProxy没用srping.aop.proxy-target-class=true/相关代码//请把代码文本粘贴到下方(请勿用图片代替代码)@ControllerpublicclassOCheckassoInfoControllerextendsBaseController{@Autowired@Resource(name="error_log")Loggererror_log;@AutowiredOCheckassoInfoInfoServiceOCheckassoInfoInfoService;@PostMapping(value="/oCheckassoInfo/queryData")@ResponseBodypublicMapqueryData(){ HashMapresult=newHashMap();try{result.put("status",EnuConfig.REQUEST_SUCCESS);result.put("data",OCheckassoInfoInfoService.queryDataAll(this.getHashDataEntity()));returnresult;}catch(Exceptione){error_log.info(e.getMessage());e.printStackTrace();result.put("status",EnuConfig.REQUEST_FAIL);result.put("data","系统错误");returnresult;}}}切面类@Aspect@ComponentpublicclassLogAop{publicLoggerservice_log=LogManager.getLogger("service");@Pointcut("execution(public*com.solantec.sensitive_fraud_yinlian.*.*.*.*())")privatevoidaspect(){}@Before(value="aspect()")publicvoidmethodBefore(JoinPointjoinPoint){ServletRequestAttributesrequestAttributes=(ServletRequestAttributes)RequestContextHolder.getRequestAttributes();HttpServletRequestrequest;service_log.info("===============requestcontext===============");if(requestAttributes!=null){request=requestAttributes.getRequest();service_log.info("requestaddr:"+request.getRequestURL().toString());service_log.info("requestmethod:"+request.getMethod());}service_log.info("params:"+Arrays.toString(joinPoint.getArgs()));service_log.info("targetmethod:"+joinPoint.getSignature());service_log.info("===============requestcontext===============");}@AfterReturning(returning="o",pointcut="aspect()")publicvoidmethodAfterReturing(Objecto){service_log.info("****************************result****************************");service_log.info("result:"+o);service_log.info("****************************result****************************");}}你期待的结果是什么?实际看到的错误信息又是什么?正常情况下控制台应该会打印两个===============requestcontext===============一个时controller的一个是service的但是service的死活就是没有
SMILET
米琪卡哇伊
相关分类