본문 바로가기

개발자가 좋은건가??/Tool

[Eclipse] Attribute 'local' is not allowed to appear in element 'ref' 메세지 수정방법

[Eclipse] Attribute 'local' is not allowed to appear in element 'ref' 메세지 수정방법




2018. 10. 26 기준


이클립스에서 Spring Framework 프로젝트시 local이 정의되어 있지 않다고 오류가 나는 경우가 있죠?


cvc-complex-type.3.2.2: Attribute 'local' is not allowed to appear in element 'ref'.


Spring Framework 4.0 업그레이드 되면서 local이 없어졌기 때문이예요. 


이를 해결하기 위해 아래와 같이 두 가지 방법이 있습니다.




첫번째. local로 되어 있는 키워드를 모두 bean으로 바꾼다.


1
2
3
4
5
<bean id="messageSourceAccessor" class="org.springframework.context.support.MessageSourceAccessor">
        <constructor-arg>
            <ref bean="messageSource"/>
        </constructor-arg>
</bean>
cs



변경전

<ref local="messageSource"/>


변경후

<ref bean="messageSource"/>


요렇게 변경하면 됩니다.




두번째. Spring Bean 3.2 로 변경한다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:aop="http://www.springframework.org/schema/aop"
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:jee="http://www.springframework.org/schema/jee"
    xmlns:lang="http://www.springframework.org/schema/lang"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xmlns:util="http://www.springframework.org/schema/util"
    xmlns:task="http://www.springframework.org/schema/task"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee.xsd
        http://www.springframework.org/schema/lang http://www.springframework.org/schema/lang/spring-lang.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd
        http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
        http://www.springframework.org/schema/task
        http://www.springframework.org/schema/task/spring-task.xsd">
cs

변경전

xsi:schemaLocation="http://www.springframework.org/schema/beans/spring-beans.xsd


변경후  

xsi:schemaLocation="http://www.springframework.org/schema/beans/spring-beans-3.2.xsd



이렇게 바꾸시면 해결됩니다. 간단하죠?