2012-07-05 64 views
5

我有我的spring-security.xml文件有問題。我想配置一些會話設置,首先創建登錄表單來維護訪客和登錄用戶。如何在Spring Security 3.1中正確配置http標記?

這是我spring-security.xml標題:

<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:security="http://www.springframework.org/schema/security" 
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.1.xsd"> 

正如你可以看到我使用Spring Security的在最新版本 - 3.1。當我嘗試將模式版本更改爲更低時,我遇到了錯誤。就3.1版本而言,我在Eclipse中只有黃色警告。

http標記看起來像:

<security:http auto-config='true'>  
    <security:intercept-url pattern="/wellcome*" access="ROLE_USER" /> 
    <security:form-login login-page="/login" default-target-url="/wellcome" authentication-failure-url="/loginfailed" /> 
    <security:logout logout-success-url="/logout" /> 
    <security:session-management invalid-session-url="/invalidsession" /> 
</security:http> 

而在此標記的第一行我有警告的長長的名單:

Multiple annotations found at this line: 
- Method 'setAuthenticationEntryPoint' is marked deprecated [config set: SpringMVC/web-context] 
- Method 'setSessionAuthenticationStrategy' is marked deprecated [config set: SpringMVC/web- 
context] 
- Method 'setUserAttribute' is marked deprecated [config set: SpringMVC/web-context] 
- Method 'setRequestCache' is marked deprecated [config set: SpringMVC/web-context] 
- Method 'setKey' is marked deprecated [config set: SpringMVC/web-context] 
- Method 'setSecurityContextRepository' is marked deprecated [config set: SpringMVC/web-context] 

Additionaly我也曾經在第三行一個警告:

Method 'setLoginFormUrl' is marked deprecated [config set: SpringMVC/web-context] 

你能否解釋我應該如何正確定義我的在Spring Security 3.1中使用http標記的文件?

回答

6

編輯:現在這個問題已在春季安全3.1.2,所以如果你使用3.1或3.1.1,請升級到新版本。

原來的答覆:

你的配置是好的。它是a known bug in Spring Security with STS in Eclipse(另見參考網址中提到的論壇話題)。

現在,您可以忽略警告,登錄https://jira.springsource.org並投票處理問題並等到問題解決(或者如果您無法忍受這些警告,請移除項目的春天性質)。

0
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans" 
    xmlns="http://www.springframework.org/schema/security" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" 
    xmlns:util="http://www.springframework.org/schema/util" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd 
     http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd 
     http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd"> 

<http auto-config="true" disable-url-rewriting="true" use-expressions="true"> 
     <form-login login-processing-url="/login" 
      login-page="/login.html" 
      default-target-url='/index.html' 
      always-use-default-target='true' 
/> 

<logout logout-url="/logout" /> 
+0

警告仍然相同。 – woyaru

相關問題