spring security的配置问题

2024-03-14

我有 Spring Security 应用程序,以下是我的 security-context.xml

<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/security"
    xmlns:beans="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/security
           http://www.springframework.org/schema/security/spring-security-3.0.3.xsd">

    <http auto-config='true'>
        <intercept-url pattern='/login*' filters='none' />
        <intercept-url pattern='/**' access='ROLE_USER' />
        <form-login login-page='/login' default-target-url='/home'
            always-use-default-target='true' />
    </http>
    <authentication-manager>
        <authentication-provider>
            <user-service>
                <user name="anto" password="anto" authorities="ROLE_USER, ROLE_ADMIN" />
                <user name="raj" password="raj" authorities="ROLE_USER" />
            </user-service>
        </authentication-provider>
    </authentication-manager>

</beans:beans>

我得到这个例外:

配置问题:无法使用 spring-security-2.0.xsd 架构 使用 Spring Security 3.0。请将您的架构声明更新为 3.0 模式。

我可以理解这个问题,但不知道在哪里改变。

我希望登录和注销表单自动出现。

EDIT : 

My pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.anto</groupId>
    <artifactId>simpleauthentication</artifactId>
    <name>SimpleAuthentication</name>
    <packaging>war</packaging>
    <version>1.0.0-BUILD-SNAPSHOT</version>
    <properties>
        <java-version>1.6</java-version>
        <org.springframework-version>3.1.1.RELEASE</org.springframework-version>
        <org.aspectj-version>1.6.10</org.aspectj-version>
        <org.slf4j-version>1.6.6</org.slf4j-version>
        <spring-security.version>3.0.2.RELEASE</spring-security.version>
    </properties>
    <dependencies>
        <!-- Spring -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>${org.springframework-version}</version>
            <exclusions>
                <!-- Exclude Commons Logging in favor of SLF4j -->
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                 </exclusion>
            </exclusions>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>${org.springframework-version}</version>
        </dependency>
                <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-core</artifactId>
            <version>${spring-security.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-config</artifactId>
            <version>${spring-security.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-web</artifactId>
            <version>${spring-security.version}</version>
        </dependency>
    <dependency>
            <groupId>org.springframework.security</groupId>
            <artifactId>spring-security-taglibs</artifactId>
            <version>${spring-security.version}</version>
        </dependency>
                 <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>1.5.4</version>
            <exclusions>
                <exclusion>
                    <groupId>commons-logging</groupId>
                    <artifactId>commons-logging</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!-- AspectJ -->
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>${org.aspectj-version}</version>
        </dependency>   

        <!-- Logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>${org.slf4j-version}</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>${org.slf4j-version}</version>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.15</version>
            <exclusions>
                <exclusion>
                    <groupId>javax.mail</groupId>
                    <artifactId>mail</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jdmk</groupId>
                    <artifactId>jmxtools</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>com.sun.jmx</groupId>
                    <artifactId>jmxri</artifactId>
                </exclusion>
            </exclusions>
            <scope>runtime</scope>
        </dependency>

        <!-- @Inject -->
        <dependency>
            <groupId>javax.inject</groupId>
            <artifactId>javax.inject</artifactId>
            <version>1</version>
        </dependency>

        <!-- Servlet -->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>servlet-api</artifactId>
            <version>2.5</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet.jsp</groupId>
            <artifactId>jsp-api</artifactId>
            <version>2.1</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>

        <!-- Test -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.7</version>
            <scope>test</scope>
        </dependency>        
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <artifactId>maven-eclipse-plugin</artifactId>
                <version>2.9</version>
                <configuration>
                    <additionalProjectnatures>
                        <projectnature>org.springframework.ide.eclipse.core.springnature</projectnature>
                    </additionalProjectnatures>
                    <additionalBuildcommands>
                        <buildcommand>org.springframework.ide.eclipse.core.springbuilder</buildcommand>
                    </additionalBuildcommands>
                    <downloadSources>true</downloadSources>
                    <downloadJavadocs>true</downloadJavadocs>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.5.1</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArgument>-Xlint:all</compilerArgument>
                    <showWarnings>true</showWarnings>
                    <showDeprecation>true</showDeprecation>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>1.2.1</version>
                <configuration>
                    <mainClass>org.test.int1.Main</mainClass>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

您的 pom.xml 和 security-context.xml 中的 Spring Security 版本错误:前者指向 3.0.2,但后者想要 3.0.3,因此:

  • 将 pom.xml 更新到 3.0.3(或更高版本)
  • or use http://www.springframework.org/schema/security/spring-security-3.0.xsd在您的安全配置中。

顺便说一句,有没有理由不使用当前 Spring Security 版本之一 http://www.springsource.org/spring-security#maven(3.0.8 / 3.1.3)?

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

spring security的配置问题 的相关文章

随机推荐

  • 实例和静态函数的重新声明

    class me private name public function construct name this gt name name public function work return You are working as th
  • SQL 列引用“id”不明确

    我尝试了以下选择 SELECT id name FROM v groups vg inner join people2v groups p2vg on vg id p2vg v group id where p2vg people id 0
  • 如何在 Haskell 中对列表进行分区?

    我想获取一个列表 或字符串 并将其拆分为 N 个元素的子列表 我该如何在 Haskell 中做到这一点 Example mysteryFunction 2 abcdefgh ab cd ef gh cabal update cabal in
  • 在 jquery 中启用/禁用下拉框

    我是 jQuery 新手 我想使用复选框启用和禁用下拉列表 这是我的html
  • 从 ruby​​-ncurses 中获取 256 种颜色

    我的终端有 256 种颜色 效果很好 测试脚本在这里 http www frexx de xterm 256 notes 但是当我使用 ncurses 通过 Ruby ncurses 时它停止工作 打印该页面上给出的转义序列工作正常 但是当
  • 这句话有什么道理呢? (Sun 对 Java 变量的命名约定)

    这几天我一直在引用Sun的文档中的这段话 直到现在我才停下来思考它在说什么 但我却无法理解它的意义 请记住 英语不是我的母语 命名约定 http java sun com docs codeconv html CodeConventions
  • Objective C 中需要指针对象

    一个非常基本的问题 但理解这些概念确实非常重要 在 C 或 C 语言中 我们通常不使用指针变量来存储值 即值简单地存储为 int a 10 但在 ios sdk 中 在 Objective C 中 我们使用的大多数对象都是通过用它们表示指针
  • 将 Laravel 事件订阅者排队

    我通过事件订阅者处理多个事件 而不是创建单独的事件 侦听器 我想对其中几个事件进行排队 但我还没有找到实现这一目标的方法 我已经关注官方了文档 https laravel com docs 5 2 events event subscrib
  • 如何获取适用于 Xcode 3.2 的 iPhone SDK 2.2.1?

    在我升级到 Snow Leopard 和 Xcode 3 2 后 我真的很后悔 Xcode 丢失了所有的 SDK 我是那些仍然想开发 2 2 1 的老式白痴之一 但苹果不向我提供旧的 SDK 下载 现在我很聪明 做了很多时间机器备份 但是
  • 在 .NET 中检测 3G 互联网连接

    我们的应用程序使用 RSS 从互联网下载数据 但在连接 3G 的计算机上出现连接问题 我们想要检测 3G EDGE GPRS 连接 以便我们可以更改应用程序行为 显示警告或连接状态 这将如何完成 The NetworkInterface h
  • Linkedin Ads API “dateRange”请求参数的格式是什么?

    dateRange 的正确格式是什么rest liv2 文档中当前的示例不支持它 我不明白rest li文档 确切地说 它的格式是什么 这是我提出的要求 Headers X Restli Protocol Version 2 0 0 Aut
  • 如何在 IntelliJ 中使用拖放来实现 java swing

    我正在使用 IntelliJ 使用 swing 进行 java 应用程序开发 使用布局管理器管理内容很困难 那么 是否有任何工具可以像 Visual Studio for vb net 一样提供拖放功能 您可以使用 IntelliJ GUI
  • 本地化 Laravel

    我一直在尝试更新网站的语言 控制器 public function getUpdateLanguage Request request request data request gt all Session put locale reque
  • 如何获取当前类的类型?

    这有点难以解释 但我到处都找过了 但找不到任何好的答案 我还看到了 Stack Overflow 的问题如何引用 Java 中接口实现的类类型 https stackoverflow com questions 8161712 how ca
  • #include 在 main() 函数中

    我想知道里面是否有可能main 来自 C 的函数来包含一些东西 例如 在 Cell 程序中 我定义了 cache api h 的参数 稍后将在main 我想改变的功能 我明白什么是定义的 define可以是未定义的 undef程序中的任何位
  • OmniAuth::NoSessionError - 您必须提供会话才能使用 OmniAuth。 (在设备中配置)

    您好 我正在学习如何使用omniauth 作为 ember 应用程序的后端 当我运行我的应用程序时 我收到下面提到的错误 OmniAuth NoSessionError 您必须提供会话才能使用 OmniAuth 在救援轨道上 我的应用程序在
  • 如何使这个 JS 函数异步?

    function takesTime for var i 0 i
  • AVFoundation 根据预览宽高比裁剪捕获的静态图像

    我的问题与这个问题大多相似 裁剪 AVCaptureSession 捕获的图像 https stackoverflow com questions 5780580 cropping image captured by avcapturese
  • 我如何将 pack uri 资源与媒体播放器一起使用?

    我有一些非常简单的代码 只需要播放指定音量的声音 如下所示 var mp new MediaPlayer mp Open uri mp Volume volume mp Play 出现问题是因为这是 Prism 模块的一部分 我不知道执行程
  • spring security的配置问题

    我有 Spring Security 应用程序 以下是我的 security context xml