如何使用多个<http>配置

时间:2017-07-04 13:17:42

标签: spring spring-security

我有两个<http>元素的文件。这两个配置不同。

<http auto-config="false" use-expressions="true" entry-point-ref="loginUrlAuthenticationEntryPoint">

<http path-type="regex" auto-config="false" realm="Protected API" use-expressions="true" create-session="never" entry-point-ref="CustomAPIAuthenticationEntryPoint">

但在部署中我收到错误

  

org.springframework.beans.factory.parsing.BeanDefinitionParsingException:配置问题:检测到重复元素   违规资源:类路径资源[websecurity-http.xml]       在org.springframework.beans.factory.parsing.FailFastProblemReporter.error(FailFastProblemReporter.java:68)       在org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:85)       在org.springframework.beans.factory.parsing.ReaderContext.error(ReaderContext.java:72)

我正在使用spring-3.0.7。有没有办法可以使用两种不同的<http>配置。我这里有两个 websecurity.xml个文件

1 个答案:

答案 0 :(得分:1)

作为@M。 Deinum和@ xerx593建议我们可以使用<http pattern=""/>

我正在使用spring-3.0.7。但是spring introduce multiple <http> element feature in spring-3.1.0。所以我不得不升级弹簧。