Closed wuyuan0717 closed 5 years ago
How can I solve this problem?
@wuyuan0717 screenshots are not a great way to get support and I am not sure to understand what you're trying to achieve by caching that login method.
LoginController will not be as a request handler.
Sorry but I don't understand what that means. Can you please a small sample that reproduces the problem you're experiencing (a zip or a link to a github repo).
@wuyuan0717 I can see you've already submitted this an hour ago #16630 and you were redirected to ask a question on StackOverflow. Ignoring a reply from the team and opening a duplicate issue is not a great way to get support either.
@snicoll when i using '@EnableCaching' open cache support ,and i add '@Cacheable' on a method that need cache support. AbstractHandlerMethodMapping can`t register it as a handler,because this beanType is 'class com.sun.proxy.$Proxy109' ,'@RestController' and '@Requesrmapping' will not find .
protected boolean isHandler(Class<?> beanType) {
return (AnnotatedElementUtils.hasAnnotation(beanType, Controller.class) ||
AnnotatedElementUtils.hasAnnotation(beanType, RequestMapping.class));
}
@snicoll The screenshot is what I want to show my LoginContoller annotations, but he is not registered as a request processing class. When I used caching, he was proxyed and the annotations ‘@Controller’、‘@RequestMapping’ could not be found
Alright, I am going to close this now. Take the time to read what I've asked you to provide and we can reopen this issue for investigations.
I'm sorry for the question I asked yesterday. I've found the reason for the problem. It turned out that there was a problem with the jar of shiro-spring-boot-web-starter I added. It adds a bean of DefaultAdvisorAutoProxyCreator by default. I set the shiro.annotations.enabled to false. All the problems have been solved.
package org.apache.shiro.spring.boot.autoconfigure;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.spring.config.AbstractShiroAnnotationProcessorConfiguration;
import org.apache.shiro.spring.security.interceptor.AuthorizationAttributeSourceAdvisor;
import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
/**
* @since 1.4.0
*/
@SuppressWarnings("SpringFacetCodeInspection")
@Configuration
@ConditionalOnProperty(name = "shiro.annotations.enabled", matchIfMissing = true)
public class ShiroAnnotationProcessorAutoConfiguration extends AbstractShiroAnnotationProcessorConfiguration {
@Bean
@DependsOn("lifecycleBeanPostProcessor")
@ConditionalOnMissingBean
@Override
public DefaultAdvisorAutoProxyCreator defaultAdvisorAutoProxyCreator() {
return super.defaultAdvisorAutoProxyCreator();
}
@Bean
@ConditionalOnMissingBean
@Override
public AuthorizationAttributeSourceAdvisor authorizationAttributeSourceAdvisor(SecurityManager securityManager) {
return super.authorizationAttributeSourceAdvisor(securityManager);
}
}
Now I have a question
Please take the time to review the guidelines before contributing again. As we've already mentioned, we prefer to use GitHub issues only for bugs and enhancements.
I have taked some time to review the guidelines. Thanks for your sincerely advise
springboot edition: 2.1.3.RELEASE
opening cache support:
adding cahce when login:
when i start my project up ,i find a problem , LoginController will not be as a request handler. maybe it had be proxied by cache support,
isHandler(beanType)
retrun false,but LoginController should be a controllerif (beanType != null && isHandler(beanType)) { detectHandlerMethods(beanName); }
16630