我正在尝试使用Apache Shiro和Stormpath保护我的Spring Web MVC项目。我在网上浏览了一些教程并通过shiro.ini文件示例获得了示例配置,并通过Spring的applicationContext.xml配置了Shiro。我试图从这两种方法中得到相同的结果。 这是shiro.ini文件:
[主要]
shiro.loginUrl = admin / login.htm
authc.successUrl = /admin/index.htm
cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager
securityManager.cacheManager = $ cacheManager
stormpathClient = com.stormpath.shiro.client.ClientFactory
stormpathClient.cacheManager = $ cacheManager
stormpathClient.apiKeyFileLocation = $ HOME / .stormpath / apiKey.properties
stormpathRealm = com.stormpath.shiro.realm.ApplicationRealm
stormpathRealm.client = $ stormpathClient
stormpathRealm.applicationRestUrl = https://api.stormpath.com/v1/applications/
stormpathRealm.groupRoleResolver.modeNames = name
securityManager.realm = $ stormpathRealm
[网址]
/ admin / ** = authc
/logout.htm =退出
以及applicationContext.xml文件中的bean定义:
<!-- https://mvnrepository.com/artifact/org.apache.shiro/shiro-spring -->
<dependency>
<groupId>org.apache.shiro</groupId>
<artifactId>shiro-spring</artifactId>
<version>1.4.0-RC2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.stormpath.shiro/stormpath-shiro-core -->
<dependency>
<groupId>com.stormpath.shiro</groupId>
<artifactId>stormpath-shiro-core</artifactId>
<version>0.8.0-RC1</version>
</dependency>
我不断收到错误说:
无法将[com.stormpath.shiro.client.ClientFactory]类型的值转换为属性&#39;客户端所需类型[com.stormpath.sdk.client.Client]:没有匹配的编辑器或转换策略
这可能是因为maven依赖性不完整:
<a href="http://wwww.google.com" onclick="window.open('http://wwww.google.com', 'newwindow', 'width=300, height=250'); return false;"> Print</a>
有人可以建议实现此目的所需的依赖项。
答案 0 :(得分:0)
您可能缺少XML中的factory-bean / factory-method元素。
另一方面,开始使用Apache Shiro和Stormpath的最简单方法是查看其中一个examples 在你的情况下可能是spring-boot-web。
通过shiro-spring-boot-starter
使用Spring的自动配置,您只需要担心method annotations。