Springboot+springcache+shiro+redis of @cacheable, @Transactional and so on during integration

Source: Internet
Author: User

Problem Description:

1.springboot integration Shiro before @cacheable, @Transactional and other annotations can be normal use;

2. When the Shiro is integrated, @cacheable, @Transaction in Roleruservice are invalidated when the roleuserservice is injected into the custom Myshirorealm.

Myshirorealm Code:

Roleuserservice Code:

Cause: Shiro and cache refer to the service instance order problem, Shiro introduction should be after the cache,

The service referenced in the realm attribute bean referenced in the Shiro configuration file takes a deferred load policy.

Workaround: @lazy annotations when Myshirorealm injects Roleuserservice (with deferred load policy)

Myshirorealm Improved Code:



Springboot+springcache+shiro+redis of @cacheable, @Transactional and so on during integration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.