Apache Shiro 编程配置
Apache Shiro Programmatic Configuration
我想使用 Shiro 编程配置并留下 shiro.ini 文件来配置我的应用程序(它已经可以很好地与 Shiro 配合使用)。
我用的是官方教程here.
这是我实现的代码:
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 或同等配置)并确保未加载默认实现。如果您分享更多关于您的应用程序的信息(它是什么类型,您如何尝试配置 Shiro,我想我们可以更直接地帮助您)
我想使用 Shiro 编程配置并留下 shiro.ini 文件来配置我的应用程序(它已经可以很好地与 Shiro 配合使用)。
我用的是官方教程here.
这是我实现的代码:
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 或同等配置)并确保未加载默认实现。如果您分享更多关于您的应用程序的信息(它是什么类型,您如何尝试配置 Shiro,我想我们可以更直接地帮助您)