http://static.springsource.org/spring/docs/1.2.9/reference/beans.html

Specifying the target bean by using the bean attribute of the ref tag is the most general form, and will allow creating a reference to any bean in the same BeanFactory/ApplicationContext (whether or not in the same XML file), or parent BeanFactory/ApplicationContext. The value of the bean attribute may be the same as either the id attribute of the target bean, or one of the values in the name attribute of the target bean.

  <ref bean="someBean"/>

Specifying the target bean by using the local attribute leverages the ability of the XML parser to validate XML id references within the same file. The value of the local attribute must be the same as the id attribute of the target bean. The XML parser will issue an error if no matching element is found in the same file. As such, using the local variant is the best choice (in order to know about errors are early as possible) if the target bean is in the same XML file.

  <ref local="someBean"/>

ApplicationContext 또는 BeanFactory 안에서 사용할 때는 bean을 쓰고 싶을 때는 ref bean 태그를 사용한다.
하지만, 하나의 파일(xml) 안에서만 쓰고 싶을 때는 ref local 태그를 쓴다.

특정 플랫폼에서 사용될 때, 같은 이름을 주어서 서로 Conflict나 예기치 않은 일이 일어나지 않는 것이 중요하기 때문에..
하나의 파일에서 처리하는 reference bean이 많을 때는 local을 쓰는 것이 좋다.

Posted by '김용환'
,