![](/img/trans.png)
[英]How to create a new Account using programmatic configuration in Apache Shiro?
[英]Apache Shiro Programmatic Configuration
我想使用Shiro程序化配置並保留shiro.ini文件來配置我的應用程序(已經可以在Shiro上正常使用)。
我在這里使用官方教程。
這是我實現的代碼:
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);
問題是當我刪除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.
謝謝
如果您使用的是Shiro的servlet插件(片段): https : //github.com/apache/shiro/blob/master/support/servlet-plugin/src/main/resources/META-INF/web-fragment.xml
您將需要直接配置Shiro(您的web.xml或等效文件),並確保未加載默認的impl。 如果您分享有關您的應用的更多信息(它是什么類型,如何配置Shiro,我想我們可以為您提供更多直接幫助)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.