我正在尝试为具有弹簧安全性的OAuth2设置REST服务器。 (服务器已经支持没有OAuth的spring-security)。现在,我尝试遵循sparklr示例,并将spring-security-oauth工件添加到我的Maven中(mvn依赖关系:树显示它可用),以及将命名空间配置添加到我的spring-security-context.xml中,但我得到的只是:
Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/security/oauth2]
浏览到http://www.springframework.org/schema/security/
,我只看到.xsd文件,但没有oauth2文件夹。那怎么办?我假设sparklr示例是一个有效的版本,那么我在做什么错呢?
这是我的spring-security-context标头:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xmlns:sec="http://www.springframework.org/schema/security"
xsi:schemaLocation="
http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-1.0.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd">
如果需要,这是Maven设置:
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth</artifactId>
<version>1.0.0.RC2</version>
</dependency>
您引用了OAuth2,但导入了OAuth1。将依赖项替换为
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>1.0.0.RELEASE</version>
</dependency>
您需要确保spring-security-oauth2 jar存在于类路径中并且可以使用
<dependency>
<groupId>org.springframework.security.oauth</groupId>
<artifactId>spring-security-oauth2</artifactId>
<version>2.4.0.RELEASE</version>
</dependency>