自定义注解日志功能与shrio框架冲突的问题
2017-06-20 11:15
483 查看
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop" xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd"> <context:component-scan base-package="com.keduox.lobs.action" /> <aop:aspectj-autoproxy /> <!--启动支持aspectJ的支持 --> <!-- <aop:config proxy-target-class="true"/> --> <!-- 启动支持aspectJ的支持 --> <mvc:annotation-driven> <mvc:message-converters> <bean class="org.springframework.http.converter.StringHttpMessageConverter"> <property name="defaultCharset" value="UTF-8" /> </bean> <bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter4" /> </mvc:message-converters> </mvc:annotation-driven> <mvc:default-servlet-handler /> <bean id="fastJsonpResponseBodyAdvice" class="com.alibaba.fastjson.support.spring.FastJsonpResponseBodyAdvice"> <constructor-arg> <list> <value>callback</value> <value>jsonp</value> </list> </constructor-arg> </bean> <!-- 视图解析器 --> <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <!-- 前缀 --> <property name="prefix" value="/WEB-INF/" /> <!-- 后缀 --> <property name="suffix" value=".jsp" /> </bean> <!-- 静态资源过滤 --> <mvc:resources location="/css/" mapping="/css/**" /> <mvc:resources location="/js/" mapping="/js/**" /> <mvc:resources location="/images/" mapping="/images/**" /> <!-- shiro的注解支持 --> <!-- 支持Shiro对Controller的方法级AOP安全控制 begin--> <!-- <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor"> <property name="proxyTargetClass" value="true" /> </bean> --> <!-- 保证实现了Shiro内部lifecycle函数的bean执行 --> <!-- <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"/> --> <!-- <bean depends-on="lifecycleBeanPostProcessor" class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" ></bean> --><!-- <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> <property name="securityManager" ref="securityManager"/> </bean> --> <!-- Handler 异常处理程序 --> <!-- shiro的注解支持 --> <bean id="lifecycleBeanPostProcessor" class="org.apache.shiro.spring.LifecycleBeanPostProcessor"></bean> <!-- <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor"/> --> <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> <property name="securityManager" ref="securityManager"/> </bean> <!-- 开启Shiro的注解,实现对Controller的方法级权限检查(如@RequiresRoles,@RequiresPermissions),需借助SpringAOP扫描使用Shiro注解的类,并在必要时进行安全逻辑验证 --> <!--配置以下两个bean即可实现此功能 --> <!-- Enable Shiro Annotations for Spring-configured beans. Only run after thelifecycleBeanProcessor has run --> <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor"> <property name="proxyTargetClass" value="true" /> </bean> <bean class="org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor"> <property name="securityManager" ref="securityManager" /> </bean> <bean id="exceptionHandler" class="com.keduox.lobs.handler.BaseExceptionHandler"/> </beans>
在这个配置文件中
原本
<!-- <bean class="org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator" depends-on="lifecycleBeanPostProcessor"/> --> 是没有注释掉的
如果使用自定义注解那么就要启用
<aop:aspectj-autoproxy /> 但是启用这个之后shiro就不能正常工作了 后来发现是:AspectJ与Shiro不兼容和Spring二次代理错误的问题 解决办法在下面的博客链接中 http://alanli7991.github.io/2016/10/21/%E5%88%87%E9%9D%A2%E7%BC%96%E7%A8%8B%E4%B8%89AspectJ%E4%B8%8EShiro%E4%B8%8D%E5%85%BC%E5%AE%B9%E5%92%8CSpring%E4%BA%8C%E6%AC%A1%E4%BB%A3%E7%90%86%E9%94%99%E8%AF%AF%E5%88%86%E6%9E%90/?utm_source=tuicool&utm_medium=referral[/code] http://www.tuicool.com/articles/NRBraev
相关文章推荐
- Spring系列之 (十六):利用Spring AOP和自定义注解实现日志功能
- Prototype功能预览十三:一个注解完成更加规范的API版本管理-极大减少dubbo框架频繁修改接口问题
- selenium的TestNG框架注解,测试集合,用例分组,依赖测试,特定顺序执行,跳过某个case执行,自定义日志,断言_06
- 一起写框架-Ioc内核容器的实现-基础功能-组件注解支持自定义的对象名(九)
- Java日志框架——JCL(Log4J,Java Logging API)转SLF4J过程中重复依赖冲突问题
- 利用Spring AOP和自定义注解实现日志功能
- 自定义注解实现权限管理框架或其它功能扩充
- Spring 自定义注解实现操作日志记录功能
- YII框架中使用CDbcriteria添加自定义条件时表别名冲突问题
- spring使用AOP和自定义注解功能添加日志管理--实用
- 关于dvd subtitle与effect效果有冲突问题(thinkvd开发日志)
- tomcat 部署自定义MBean 之二 解决加载冲突的问题
- 自定义插件框架中嵌入python脚本环境的注意问题
- thinkphp框架使用PHPMailer实现发送邮件的功能,以及各种问题解析
- 解决jquery$命名符和其它框架的冲突问题
- 解决自定义$(id)的方法与jquery选择器冲突的问题
- php之框架增加日志记录功能类
- Python:通过自定义系统级快捷键来控制程序开始或停止记录日志(使用小技巧解决一个貌似无解的问题)
- 使用redmine的自定义问题状态以及工作流功能
- 利用Spring AOP与action注解为系统增加日志功能