Project scenario:
When using Shiro for authority authentication, the login address always carries the jeonid automatically for the first access. Now it needs to be removed and cannot be displayed.
Problem Description:
First, I searched Baidu and found that most solutions are to set SessionManager when defaultwebsecuritymanager is injected. This method also needs Shiro 1.3.2 or above. Coincidentally, my 1.3.0 is definitely not good. Go to POM directly to change the version number
annotation method:
@Bean
public DefaultWebSessionManager sessionManager(){
DefaultWebSessionManager sessionManager = new DefaultWebSessionManager();
sessionManager.setSessionIdUrlRewritingEnabled(false);
return sessionManager;
}
@Bean
public DefaultWebSecurityManager securityManager(){
DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
securityManager.setSessionManager(sessionManager());
return securityManager;
}
XML mode:
<bean id="sessionManager" class="org.apache.shiro.web.session.mgt.DefaultWebSessionManager">
<property name="sessionIdUrlRewritingEnabled" value="false"/>
</bean>
<!-- Shiro Security Manager -->
<bean id="securityManager" class="org.apache.shiro.web.mgt.DefaultWebSecurityManager">
<property name="sessionManager" ref="sessionManager"/>
</bean>
Remember to add package scanning in XML mode.My:
<context:component-scan base-package="config" />
Then run the project and report the same error as before. Anyway, there is no getter method.
Cause analysis:
During debugging, it is found that there are three versions of Shiro in the project, and two are from other modules, so it doesn’t matter. However, during debugging, it is found that the number of lines is not matched. After downloading the source code, it is found that this.sessionidurlrewritingenabled = true; There are no breakpoints in this line, and then the rebuild project, MVN clean install, repackaging and restarting idea are all used, and then the breakpoints can be interrupted. However, after debugging starts, the breakpoint icon turns into a circle slash, which is not the Shiro version of my current project at all
finally, you can only guess whether there are problems with multiple versions at the same time.
Solution:
It is found that one of the three versions is very old 1.2.4, but there is no place to import the whole project. Then, according to the warehouse, it is still imported in the way of Shiro all, so the name is temporarily modified. After running the project, it can run as expected
Read More:
- [Solved] SpringMVC Shiro Error: org.apache.shiro.UnavailableSecurityManagerException No SecurityManager
- [Solved] shiro Error: org.apache.shiro.authc.UnknownAccountException:
- Customize the jump address after Shiro logout
- [Solved] shiro Error: SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder“.
- Springboot integration shiro error: UnsatisfiedDependencyException: Error creating bean with name ‘getShiroFilterFact
- When the database table field is set to self incrementing, use the entity class to insert or update the data to solve the error (Hibernate Framework)
- How to Solve JUnit Debugging initializationerror ERROR
- How to Solve SSM JSON Chinese Messy Code Issue
- How to Solve Flick operate Error: not serialized
- How to Solve Error:java.io.InvalidClassException
- How to Solve Nosuchmethoderror Error
- How to Solve SQL comments error in the mybatis query
- How to Solve RAR Files Extract Error with sevenzipjbinding (Multithread Processing)
- How to Solve Java Runtime (class file version 53.0)ERROR
- How to Solve Error: No suitable driver found for
- How to Solve mybatis-plus Paging Plug-in PaginationInnerInterceptor error
- How to Solve Log4j 2.5 upgrade to 2.15 error
- How to Solve JDBC connection error in spring MVC integration
- How to Solve ERROR: Java 1.7 or later is required to run Apache Drill
- How to Solve Flynk Task Java verifyerror 209 error