[英]Apache Shiro Programmatic Configuration
I would like to configure my application (that already works fine with Shiro) using Shiro programmatic configuration and leaving shiro.ini file. 我想使用Shiro程序化配置并保留shiro.ini文件来配置我的应用程序(已经可以在Shiro上正常使用)。
I use the official tutorial here . 我在这里使用官方教程。
This is the code i implemented: 这是我实现的代码:
Realm realm = new AuthAuthRealmFactory();
org.apache.shiro.mgt.SecurityManager securityManager = new DefaultSecurityManager(realm);
//Make the SecurityManager instance available to the entire application via static memory:
SecurityUtils.setSecurityManager(securityManager);
The problem is when i remove shiro.ini file i experience this exception: 问题是当我删除shiro.ini文件时,我遇到此异常:
> org.apache.shiro.web.env.IniWebEnvironment - Checking
> any specified config locations.
> - org.apache.shiro.web.env.IniWebEnvironment - No INI instance or config locations specified. Trying default config
> locations. - org.apache.shiro.io.ResourceUtils
> - Opening resource from class path [shiro.ini] - org.apache.shiro.util.ClassUtils - Resource [shiro.ini] was not found via the thread context ClassLoader.
> Trying the current ClassLoader... - org.apache.shiro.util.ClassUtils
> - Resource [shiro.ini] was not found via the current class loader. Trying the system/application ClassLoader... -
> org.apache.shiro.util.ClassUtils - Resource
> [shiro.ini] was not found via the thread context, current, or
> system/application ClassLoaders. All heuristics have been exhausted.
> Returning null. - org.apache.shiro.web.env.IniWebEnvironment
> - Unable to load optional path 'classpath:shiro.ini'.
> - java.io.IOException: Resource [classpath:shiro.ini] could not be found.
Thanks 谢谢
If you are using Shiro's servlet plugin (fragment): https://github.com/apache/shiro/blob/master/support/servlet-plugin/src/main/resources/META-INF/web-fragment.xml 如果您使用的是Shiro的servlet插件(片段): https : //github.com/apache/shiro/blob/master/support/servlet-plugin/src/main/resources/META-INF/web-fragment.xml
You would need to configure Shiro directly (either your web.xml or equivalent) and make sure the default impl is not loaded. 您将需要直接配置Shiro(您的web.xml或等效文件),并确保未加载默认的impl。 If you share a little more about your app (what type is it, how are you trying to configure Shiro, I'm guessing we can help you more directly)
如果您分享有关您的应用的更多信息(它是什么类型,如何配置Shiro,我想我们可以为您提供更多直接帮助)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.