启动类已配置
@Configuration
@ComponentScan(basePackages = "com.xx.*")
@EnableAspectJAutoProxy(proxyTargetClass=true)
//@PropertySource("classpath:datasource.properties")
@EnableTransactionManagement
public class AppContextConfig {
切面如下
@Service
//@Lazy(value=false)
@Aspect
public class RestfulAspect {
private final Logger log = LoggerFactory.getLogger(this.getClass());
@PostConstruct
public void d(){
log.info("eiedoododdo");
}
// @Pointcut("@annotation(com.xx.filters.ResPack)")
// public void anyRequestMappingMethod() {
// }
@Pointcut("execution(* com.xx.rest.*.*(..))")
public void anyControllerMethod() {
}
@Around("anyControllerMethod()") //&& anyRequestMappingMethod()
public Object ensulate(ProceedingJoinPoint pjp){
Map<String,Object> retMap=new HashMap<String,Object>();
try {
Object obj=pjp.proceed();
retMap.put("data", obj);
retMap.put("success", true);
retMap.put("message", "操作成功");
} catch (ServiceException e) {
retMap.put("success", false);
retMap.put("message", e.getMessage());
} catch (Throwable e) {
retMap.put("success", false);
retMap.put("message", "系统错误!");
log.error("system exception",e);
}
return retMap;
}
}
可是解释拦截不到。求帮助
少了注释
@component