spring boot 事务无法开启

提问 9 4445
雨中豪杰
雨中豪杰 2019-03-20
版本:renren-security 1.1 开发环境:
[security-enterprise1.1_专业版]项目启动时,spring事务检查器提示bean的自动代理不合格,所以事务管理器无法管理类的事务,这个问题如何解决 2019-03-20 15:12:44.741 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'shiroConfig' of type [io.renren.common.config.ShiroConfig$$EnhancerBySpringCGLIB$$b67e9638] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:44.844 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.boot.context.properties.ConversionServiceDeducer$Factory' of type [org.springframework.boot.context.properties.ConversionServiceDeducer$Factory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:44.928 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'mybatis-plus-com.baomidou.mybatisplus.spring.boot.starter.MybatisPlusProperties' of type [com.baomidou.mybatisplus.spring.boot.starter.MybatisPlusProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:44.935 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'mybatisPlusConfig' of type [io.renren.common.config.MybatisPlusConfig$$EnhancerBySpringCGLIB$$6201a814] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:44.946 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'paginationInterceptor' of type [com.baomidou.mybatisplus.plugins.PaginationInterceptor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:44.955 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'com.baomidou.mybatisplus.spring.boot.starter.MybatisPlusAutoConfiguration' of type [com.baomidou.mybatisplus.spring.boot.starter.MybatisPlusAutoConfiguration$$EnhancerBySpringCGLIB$$5e12fa8c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:44.960 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'dynamicDataSourceConfig' of type [io.renren.commons.datasources.DynamicDataSourceConfig$$EnhancerBySpringCGLIB$$4fcdee] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:45.011 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.datasource-org.springframework.boot.autoconfigure.jdbc.DataSourceProperties' of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:45.016 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'com.alibaba.druid.spring.boot.autoconfigure.stat.DruidFilterConfiguration' of type [com.alibaba.druid.spring.boot.autoconfigure.stat.DruidFilterConfiguration] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:45.047 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'statFilter' of type [com.alibaba.druid.filter.stat.StatFilter] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:45.070 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'defaultDataSource' of type [com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceWrapper] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:45.081 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'firstDataSource' of type [com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceWrapper] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:45.090 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'secondDataSource' of type [com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceWrapper] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:45.097 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'dataSource' of type [io.renren.commons.datasources.DynamicDataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:45.437 INFO 15920 --- [ main] com.alibaba.druid.pool.DruidDataSource : {dataSource-1} inited 2019-03-20 15:12:45.995 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'sqlSessionFactory' of type [org.apache.ibatis.session.defaults.DefaultSqlSessionFactory] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:46.004 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'sqlSessionTemplate' of type [org.mybatis.spring.SqlSessionTemplate] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:46.005 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'sysMenuDao' of type [org.mybatis.spring.mapper.MapperFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:46.007 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'sysMenuDao' of type [com.sun.proxy.$Proxy76] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:46.010 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'sysUserDao' of type [org.mybatis.spring.mapper.MapperFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:46.011 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'sysUserDao' of type [com.sun.proxy.$Proxy77] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:46.014 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'sysUserTokenDao' of type [org.mybatis.spring.mapper.MapperFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:46.015 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'sysUserTokenDao' of type [com.sun.proxy.$Proxy78] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:46.016 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'shiroServiceImpl' of type [io.renren.modules.sys.service.impl.ShiroServiceImpl] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:46.016 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'OAuth2Realm' of type [io.renren.modules.sys.oauth2.OAuth2Realm] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:46.246 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'securityManager' of type [org.apache.shiro.web.mgt.DefaultWebSecurityManager] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 2019-03-20 15:12:46.315 INFO 15920 --- [ main] trationDelegate$BeanPostProcessorChecker : Bean 'authorizationAttributeSourceAdvisor' of type [org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
回帖
  • 修改ShiroConfig.java 删除下面代码: [pre] @Bean public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() { DefaultAdvisorAutoProxyCreator proxyCreator = new DefaultAdvisorAutoProxyCreator(); proxyCreator.setProxyTargetClass(true); return proxyCreator; } [/pre] 这个问题在最新版里已经解决
    0 回复
  • 雨中豪杰
    2019-03-20
    @Mark 你好,刚才尝试删除了,但是依旧还是有那个提示,因为我们项目已经定型了,所以没法升级最新版本,能否再给指点一下?
    0 回复
  • @雨中豪杰 事务不生效,还是怎么呢
    0 回复
  • 雨中豪杰
    2019-03-20
    @Mark 现在是事务不生效,而且不是全部不生效,就日志中输出 is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying) 提示的都不好用
    0 回复
  • 雨中豪杰
    2019-03-20
    @Mark 代码分析上感觉应该是shiroConfig的问题,因为如果删除了这个类,就没有问题了
    0 回复
  • @雨中豪杰 使用多数据源了吗
    0 回复
  • 雨中豪杰
    2019-03-21
    @Mark 没有使用多数据源 [pre] spring: datasource: type: com.alibaba.druid.pool.DruidDataSource driverClassName: com.mysql.jdbc.Driver druid: url: jdbc:mysql://172.16.71.180:3806/zhongliang?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false username: root password: root initial-size: 10 max-active: 100 min-idle: 10 max-wait: 60000 pool-prepared-statements: true max-pool-prepared-statement-per-connection-size: 20 time-between-eviction-runs-millis: 60000 min-evictable-idle-time-millis: 300000 #validation-query: SELECT 1 FROM DUAL test-while-idle: true test-on-borrow: false test-on-return: false stat-view-servlet: enabled: true url-pattern: /druid/* filter: stat: log-slow-sql: true slow-sql-millis: 1000 merge-sql: false wall: config: multi-statement-allow: true redis: database: 0 host: 172.16.71.180 port: 6879 password: [/pre]
    0 回复
  • 雨中豪杰
    2019-03-21
    @Mark [pre] # Tomcat server: tomcat: uri-encoding: UTF-8 max-threads: 1000 min-spare-threads: 30 port: 8080 connection-timeout: 5000ms servlet: context-path: /admin session: cookie: http-only: true spring: # 环境 dev|test|prod profiles: active: dev # jackson时间格式化 jackson: time-zone: GMT+8 date-format: yyyy-MM-dd HH:mm:ss servlet: multipart: max-file-size: 100MB max-request-size: 100MB enabled: true redis: database: 0 host: 192.168.10.10 port: 6379 password: # 密码(默认为空) timeout: 6000ms # 连接超时时长(毫秒) jedis: pool: max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) max-idle: 10 # 连接池中的最大空闲连接 min-idle: 5 # 连接池中的最小空闲连接 jedis: pool: max-active: 1000 # 连接池最大连接数(使用负值表示没有限制) max-wait: -1ms # 连接池最大阻塞等待时间(使用负值表示没有限制) max-idle: 10 # 连接池中的最大空闲连接 min-idle: 5 # 连接池中的最小空闲连接 activiti: check-process-definitions: false messages: basename: i18n.baseErr,i18n.baseCommonErr,i18n.baseOssErr,i18n.baseMsgErr,i18n.baseJobErr,i18n.baseActErr fdfs: so-timeout: 600000 connect-timeout: 6000 tracker-list: #TrackerList参数,支持多个 - 192.168.10.10:22122 dhc: redis: open: true # 是否开启redis缓存 true开启 false关闭 #mybatis mybatis-plus: mapper-locations: classpath*:mapper/**/*.xml #实体扫描,多个package用逗号或者分号分隔 typeAliasesPackage: com.dhc.modules.*.entity global-config: #主键类型 0:"数据库ID自增", 1:"用户输入ID",2:"全局唯一ID (数字类型唯一ID)", 3:"全局唯一ID UUID"; id-type: 0 #字段策略 0:"忽略判断",1:"非 NULL 判断"),2:"非空判断" field-strategy: 1 #驼峰下划线转换 db-column-underline: true logic-delete-value: -1 logic-not-delete-value: 0 #自定义SQL注入器 sql-injector: com.baomidou.mybatisplus.mapper.LogicSqlInjector configuration: map-underscore-to-camel-case: true cache-enabled: false call-setters-on-nulls: true login: expire: 1800 platform: admin [/pre]
    0 回复
  • 雨中豪杰
    2019-03-21
    @Mark 这是shiroConfig代码,即使 [defaultAdvisorAutoProxyCreator] 方法被删除了,也依旧不好用 [pre] @Configuration public class ShiroConfig { @Bean("securityManager") public SecurityManager securityManager(OAuth2Realm oAuth2Realm) { DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager(); securityManager.setRealm(oAuth2Realm); securityManager.setRememberMeManager(null); return securityManager; } @Bean("shiroFilter") public ShiroFilterFactoryBean shirFilter(SecurityManager securityManager, @Autowired(required = false) List<ShiroConfigParam> shiroConfigParams, @Autowired List<FetchTokenHandler> fetchTokenHandlers) { ShiroFilterFactoryBean shiroFilter = new ShiroFilterFactoryBean(); shiroFilter.setSecurityManager(securityManager); //oauth过滤 Map<String, Filter> filters = new HashMap<>(); filters.put("oauth2", new OAuth2Filter(fetchTokenHandlers)); Optional.ofNullable(shiroConfigParams).orElse(Collections.emptyList()).forEach(o -> { filters.putAll(Optional.ofNullable(o).map(ShiroConfigParam::addFilters).orElse(Collections.emptyMap())); }); shiroFilter.setFilters(filters); Map<String, String> filterMap = new LinkedHashMap<>(); filterMap.put("/webjars/**", "anon"); filterMap.put("/druid/**", "anon"); filterMap.put("/sys/login", "anon"); filterMap.put("/swagger/**", "anon"); filterMap.put("/v2/api-docs", "anon"); filterMap.put("/swagger-ui.html", "anon"); filterMap.put("/swagger-resources/**", "anon"); filterMap.put("/service/**", "anon"); filterMap.put("/editor-app/**", "anon"); filterMap.put("/diagram-viewer/**", "anon"); filterMap.put("/modeler.html", "anon"); filterMap.put("/captcha.jpg", "anon"); filterMap.put("/favicon.ico", "anon"); Optional.ofNullable(shiroConfigParams).orElse(Collections.emptyList()).forEach(o -> { filterMap.putAll(Optional.ofNullable(o).map(ShiroConfigParam::addFilterChainDefinitionMap).orElse(Collections.emptyMap())); }); filterMap.put("/**", "oauth2"); shiroFilter.setFilterChainDefinitionMap(filterMap); return shiroFilter; } @Bean("lifecycleBeanPostProcessor") public LifecycleBeanPostProcessor lifecycleBeanPostProcessor() { return new LifecycleBeanPostProcessor(); } @Bean public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() { DefaultAdvisorAutoProxyCreator proxyCreator = new DefaultAdvisorAutoProxyCreator(); proxyCreator.setProxyTargetClass(true); return proxyCreator; } @Bean public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) { AuthorizationAttributeSourceAdvisor advisor = new AuthorizationAttributeSourceAdvisor(); advisor.setSecurityManager(securityManager); return advisor; } } [/pre]
    0 回复