Программная конфигурация Apache Shiro - PullRequest
0 голосов
/ 06 февраля 2019

Я хотел бы настроить свое приложение (которое уже отлично работает с Shiro), используя программную настройку Shiro и оставляя файл shiro.ini.

Я использую официальный учебник здесь .

Это код, который я реализовал:

    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.

Спасибо

1 Ответ

0 голосов
/ 06 февраля 2019

Если вы используете плагин сервлета Shiro (фрагмент): https://github.com/apache/shiro/blob/master/support/servlet-plugin/src/main/resources/META-INF/web-fragment.xml

Вам нужно будет настроить Shiro напрямую (либо ваш web.xml или эквивалентный) и убедиться, что impl по умолчанию не загружен.Если вы поделитесь немного больше о вашем приложении (какой у вас тип, как вы пытаетесь настроить Shiro, я думаю, мы можем помочь вам более напрямую)

...