springboot项目下,提示shiro与aop冲突

我用的是springboot微框架。权限管控用的shiro,现在要使用aop,总是报以下错误:
Error creating bean with name 'shiroFilterFactoryBean' defined in class path resource [com/zcy/salesPlatform/shiro/ShiroConfig.class]: BeanPostProcessor before instantiation of bean failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.transaction.annotation.ProxyTransactionManagementConfiguration': Initialization of bean failed; nested exception is java.lang.IllegalArgumentException: Pointcut is not well-formed: expecting 'identifier' at character position 0

  • com.zcy.salesPlatform.action.sell.order.*.*(..)

我的aop类:

 package com.zcy.salesPlatform.aop;

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;

@Aspect
@Component
public class LoggerAop {

    @Pointcut("* com.zcy.salesPlatform.action.sell.order.*.*(..)")
    public void loggerAspect(){}

    @Before("loggerAspect()")
    public void before() {
        System.out.println("切面before执行了");
    }

    /*@After("loggerAspect()")
    public void after() {
        System.out.println("切面after执行了");
    }

    @AfterReturning("loggerAspect()")
    public void afterReturning() {
        System.out.println("切面afterReturning执行了");
    }

    @AfterThrowing("loggerAspect()")
    public void afterThrowing() {
        System.out.println("切面afterThrowing执行了");
    }*/

    /*@Around("loggerAspect()")
    public Object around(ProceedingJoinPoint thisJoinPoint){
        Object obj = null;
        System.err.println ("切面around before执行了");
        try {
            thisJoinPoint.proceed();
        } catch (Throwable e) {
            e.printStackTrace ();
        }
        System.err.println ("切面around after执行了");
        return obj;
    }*/
}

我的shiro。config类:

 package com.zcy.salesPlatform.shiro;

import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.shiro.spring.LifecycleBeanPostProcessor;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * spring boot 集成shiro的配置 http://blog.csdn.net/catoop/article/details/50520958
 * 
 * @author luanhaibin
 */

@Configuration
public class ShiroConfig {

    private static Map<String, String> filterChainDefinitionMap = new LinkedHashMap<String, String>();

    @Bean(name = "shiroFilterFactoryBean")
    public ShiroFilterFactoryBean shiroFilterFactoryBean() {
        ShiroFilterFactoryBean shiroFilterFactoryBean = new ShiroFilterFactoryBean();
        shiroFilterFactoryBean.setSecurityManager(securityManager());
        shiroFilterFactoryBean.setLoginUrl("/user/login");
        shiroFilterFactoryBean.setSuccessUrl("/menu/menuIndex");
//      
        filterChainDefinitionMap.put("/menu/**", "authc");
//      filterChainDefinitionMap.put("/personcenter/**", "authc");
        filterChainDefinitionMap.put("/**", "anon");
//      
        shiroFilterFactoryBean.setFilterChainDefinitionMap(filterChainDefinitionMap);
        return shiroFilterFactoryBean;
    }

    @Bean(name = "securityManager")
    public DefaultWebSecurityManager securityManager() {
        DefaultWebSecurityManager defaultWebSecurityManager = new DefaultWebSecurityManager();
        defaultWebSecurityManager.setRealm(shiroRealm());

        return defaultWebSecurityManager;
    }

    @Bean(name = "shiroRealm")
    public ShiroRealm shiroRealm() {
        return new ShiroRealm();
    }

    @Bean(name = "lifecycleBeanPostProcessor")
    public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() {
//      AbstractNativeSessionManager a=new  AbstractNativeSessionManager();
        return new LifecycleBeanPostProcessor();
    }



}

请教各位老师各位大神,怎么破?

3个回答

@Pointcut("* com.zcy.salesPlatform.action.sell.order.*.*(..)")
这一段写的是否有问题啊?
写成这样 :
@Pointcut ("execution ( public * com.zcy.salesPlatform.action.sell.order.*.*(..))")
貌似这个execution 是表达式最关键的地方吧

T1358696550
舊歡如夢 正解,其实之前是有exeuction的,我换了好几次切面规则都报错才考虑是不是和aop冲突了,这里是发上来的时候忘了撤销。不过你的切面规则是对的。
大约 3 年之前 回复

注册一下servlet和filter,springboot和spring不一样,默认不注册servlet和filter的

我这也不行,楼主解决了吗?用了他们整合,导致报错point.proceed();为空

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问