component-scan 관련 질문 드립니다.
- 작성자 :
- 임*화
- 작성일 :
- 2024-01-03 13:40:34
- 조회수 :
- 637
- 구분 :
- 개발환경 / 3.10
- 진행상태 :
- 완료
Q
dispatcher-servlet.xml
-----------------------------------------------------------------------------------------------------------------------------
<context:component-scan base-package="egovframework">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
-----------------------------------------------------------------------------------------------------------------------------
conetxt-common.xml
-----------------------------------------------------------------------------------------------------------------------------
<context:component-scan base-package="egovframework">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>
<context:include-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
-----------------------------------------------------------------------------------------------------------------------------
위와 같이 dispatcher-servlet.xml 에서는 Controller 만 include 하고,
conetxt-common.xml 에서는 Service, Repository 를 include 하도록 나누어 놓은 이유가 있나요??
나누어 놓은 이유가 무엇이며, 한군데만 설정을 해도 되는지 궁금합니다.
dispatcher-servlet.xml
-----------------------------------------------------------------------------------------------------------------------------
<context:component-scan base-package="egovframework">
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
-----------------------------------------------------------------------------------------------------------------------------
conetxt-common.xml
-----------------------------------------------------------------------------------------------------------------------------
<context:component-scan base-package="egovframework">
<context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
<context:include-filter type="annotation" expression="org.springframework.stereotype.Service"/>
<context:include-filter type="annotation" expression="org.springframework.stereotype.Repository"/>
</context:component-scan>
-----------------------------------------------------------------------------------------------------------------------------
위와 같이 dispatcher-servlet.xml 에서는 Controller 만 include 하고,
conetxt-common.xml 에서는 Service, Repository 를 include 하도록 나누어 놓은 이유가 있나요??
나누어 놓은 이유가 무엇이며, 한군데만 설정을 해도 되는지 궁금합니다.
환경정보
-
- OS 정보 : Windows 11
- 표준프레임워크 버전 : 3.10
- JDK(JRE) 정보 : 1.7
- WAS 정보 : Tomcat8.5
- DB 정보 : Oracle
- 기타 환경 정보 :
A
안녕하세요.
표준프레임워크센터입니다.
dispatcher-servlet.xml은 주로 웹 계층에서 동작하는 컨트롤러를 포함한
웹 관련 Bean을 포함하고 WebApplicationContext에서 관리되며
conetxt-common.xml은 비즈니스 로직을 담당하는 서비스와 데이터액세스 객체를 포함한
웹 환경에 독립적인 Bean들을 포함하고 Root ApplicationContext에서 괸리됩니다.
이렇게 구성한 이유는 전체 애플리케이션에서 웹 기술에 의존적인 부분과 그렇지 않은 부분을 구분할 필요가 있으며
스프링 애플리케이션을 구성하는 레이어별로 설정을 나눠 레이어간의 결합도를 낮추고
코드의 가독성이나 유지보수성을 높이고 확장성을 향상시키는데 도움이 되어
분리된 설정파일을 사용하는 것을 권장합니다.
감사합니다.
표준프레임워크센터입니다.
dispatcher-servlet.xml은 주로 웹 계층에서 동작하는 컨트롤러를 포함한
웹 관련 Bean을 포함하고 WebApplicationContext에서 관리되며
conetxt-common.xml은 비즈니스 로직을 담당하는 서비스와 데이터액세스 객체를 포함한
웹 환경에 독립적인 Bean들을 포함하고 Root ApplicationContext에서 괸리됩니다.
이렇게 구성한 이유는 전체 애플리케이션에서 웹 기술에 의존적인 부분과 그렇지 않은 부분을 구분할 필요가 있으며
스프링 애플리케이션을 구성하는 레이어별로 설정을 나눠 레이어간의 결합도를 낮추고
코드의 가독성이나 유지보수성을 높이고 확장성을 향상시키는데 도움이 되어
분리된 설정파일을 사용하는 것을 권장합니다.
감사합니다.