Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring security http and authentication-provider not declared

I was trying to integrating Spring security into my existing project. The tools that I am using are:

  1. Spring 2.5.6.SEC03
  2. spring-security-core 3.1.1.RELEASE
  3. JDK 7.

In spring configuration, I have this:

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

<http auto-config='true'>
  <intercept-url pattern="/messagePost.htm*" access="ROLE_USER"/>
</http>

<authentication-provider>
  <user-service>
    <user name="user1" password="1111" authorities="ROLE_USER"/>
  </user-service>
</authentication-provider>
</beans:beans>

But there is an error on this spring configuration:

  1. cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'authentication-provider'.
  2. cvc-complex-type.2.4.c: The matching wildcard is strict, but no declaration can be found for element 'http'.

May I know how to resolve this issue?

like image 699
huahsin68 Avatar asked Feb 17 '26 03:02

huahsin68


1 Answers

MaKe these changes

<?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.1.xsd
        http://www.springframework.org/schema/security
        http://www.springframework.org/schema/security/spring-security-3.1.xsd">

  <http auto-config='true'>
    <intercept-url pattern="/messagePost.htm*" access="ROLE_USER"/>
  </http>

  <authentication-manager>
    <authentication-provider>
      <user-service>
        <user name="user1" password="1111" authorities="ROLE_USER"/>
      </user-service>
    </authentication-provider>
  </authentication-manager>

</beans:beans>

I have done the following changes

  1. Changed your xmlns schema from "http://springframework.org/schema/security"to "http://www.springframework.org/schema/security" (added www :D)
  2. I have enclosed the <authentication-provider> namespace inside a <authentication-manager> namespace.
like image 142
shazinltc Avatar answered Feb 18 '26 19:02

shazinltc



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!