Spring-Security OAuth2设置 - 无法找到oauth2命名空间处理程序

时间:2013-01-03 10:26:59

标签: spring spring-security oauth-2.0 xml-namespaces

我正在尝试使用spring-security为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>

2 个答案:

答案 0 :(得分:7)

您引用OAuth2但导入OAuth 1.将依赖项替换为

<dependency>
    <groupId>org.springframework.security.oauth</groupId>
    <artifactId>spring-security-oauth2</artifactId>
    <version>1.0.0.RELEASE</version>
</dependency>

答案 1 :(得分:0)

您需要确保classpath中存在spring-security-oauth2 jar并且它可以工作

<dependency>
  <groupId>org.springframework.security.oauth</groupId>
  <artifactId>spring-security-oauth2</artifactId>
  <version>2.4.0.RELEASE</version>
</dependency>