본문 바로가기

spring/Annotation

어노 테이션을 사용하기 위한 설정

<?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:context="http://www.springframework.org/schema/context"

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

http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">


  <!-- 어노테이션을 사용한다고 선언해줌 -->

  <context:annotation-config/>


<context:component-scan base-package="pack.test"/>

 

  <!-- 


<context:component-scan base-package="pack.test"/> :


명시된 package안의 class들의 어노테이션을 스캔해서 설정해줌 


  <context:component-scan base-package="pack.test"/> 을 사용했다면


  위의 <context:annotation-config/> 사용하지 않아도됨

 

  하지만 


  <context:annotation-config/> 만 사용하고

 

<context:component-scan base-package="anno2_auto"/>을 사용하지 않으면 Component(@Service) 어노테이션이 작동하지 않음

 

-->


</beans>

'spring > Annotation' 카테고리의 다른 글

@Value, Spring EL  (0) 2014.05.07
@Resource  (0) 2014.05.02
@component : @Service,@Repository,@Controller  (0) 2014.05.02
@Autowired  (2) 2014.05.02
@Required  (0) 2014.05.02