Reputation: 3274
I want to use Spring security so configured like this
<?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.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.0.xsd">
<http>
<intercept-url pattern="/add-job**" access="hasRole('USER')" />
<form-login />
<logout />
</http>
<authentication-manager>
<authentication-provider>
<user-service>
<user name="admin" password="admin" authorities="ROLE_USER, ROLE_ADMIN" />
</user-service>
</authentication-provider>
</authentication-manager>
</beans:beans>
but I'm getting errors as
Multiple annotations found at this line: - schema_reference.4: Failed to read schema document 'http://www.springframework.org/schema/ security/spring-security-4.0.xsd', because 1) could not find the document; 2) the document could not be read; 3) the root element of the document is not . - cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'http'.
and
and my pom.xml for Security is
<!-- Security -->
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
<version>4.0.2.RELEASE</version>
</dependency>
I can not find way to fix this issue.
Upvotes: 2
Views: 5685
Reputation: 3274
Thanks to Answering Guys, but finally I've found a solution at Migrating from Spring Security 3.x to 4.x (XML Configuration), and found the following dependency
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>4.0.0.RELEASE</version>
</dependency>
this with along side of mentioned in Question, this approach solved my problem.
Upvotes: 3
Reputation: 4223
Spring recommends to use this http://www.springframework.org/schema/security/spring-security.xsd
instead specifying version number, as you do with spring-beans
.
This way, I have a project with the same spring security dependencies, but instead 4.0.2.RELEASE
I have 4.0.1.RELEASE
and it is working with no problems.
So you have to try schema configuration as follows:
xsi:schemaLocation="
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd"
If it doesn't work, then you may have a transitive dependency problem and you are simply loading two or more different spring security versions. In this case try using mvn dependency:tree
to see if you have more than one spring-security depedency on configuration
artifact, and exclude the one you don't need.
Upvotes: 1