springspring-mvcspring-securityspring-security-ldapspring-security-acl

Spring security intercept method shows error


    <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"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
    http://www.springframework.org/schema/context
    http://www.springframework.org/schema/context/spring-context-2.5.xsd
    http://www.springframework.org/schema/security
    http://www.springframework.org/schema/security/spring-security-2.0.1.xsd">

<bean id="messageBoardService" 
    class="com.service.MessageBoardServiceImpl">
    <security:intercept-methods>
    <security:protect 
        method="com.service.MessageBoardService.listMessages"
        access="ROLE_USER,ROLE_GUEST" />
    <security:protect 
        method="com.service.MessageBoardService.postMessage"
        access="ROLE_USER" />
    <security:protect 
        method="com.service.MessageBoardService.deleteMessage"
        access="ROLE_ADMIN,IP_LOCAL_HOST" />
    <security:protect 
        method="com.service.MessageBoardService.findMessageById"
        access="ROLE_USER,ROLE_GUEST" />
    </security:intercept-methods>
</bean>

by executing the above lines of code its showing error

The matching wildcard is strict, but no declaration can be found for element 'bean'

and getting red underline on security intercept method tag

here are the list of jar files enter image description here


Solution

  • This header when added to the xml file. It works correct

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