donaricano-btn

비즈니스 로직 Bean 정의 파일


1. beans-biz.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
    xsi:schemaLocation="
     
    <!-- 1 -->
    <context:component-scan base-package="sample.customer.biz.service"/>
     
    <!-- 2 -->
    <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
        <property name="basename" value="classpath:/META-INF/messages"/>
    </bean>  
     
    <!-- 3 -->
    <bean id="validator" class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
        <property name="validationMessageSource" ref="messageSource"/>
    </bean>
 
</beans>


1) 서비스 클래스를 자동으로 DI 컨테이너에 등록함

2) 메시지 관리 설정

- ReloadableResourceBundleMessageSource 클래스는 MessageSource인터페이스의 구현 클래스 이다

- 구현 클래스는 메시지 리소스 파일의 정기적인 리로드와 메시지 캐시등을 지원한다

- basename은 경로에 있는 메시지 리소스 파일을 불러온다(message.properties, /META-INF/messages_{언어코드}.properties)

ex) messages_kr.properties,  message_en.properties

3) Bean검증

- validator 라는 이름으로 DI 컨테이너에 등록된다

- 스프링의 MessageSource 오브젝트와 연계가능하며 그 설정이 property 항목이다



'FullStack > SimpleSpringMVC' 카테고리의 다른 글

[SpringMVC] controller & jsp  (0) 2016.09.18
[SpringMVC] 레이어 구조  (0) 2016.08.21
[SpringMVC] web.xml 설정  (0) 2016.08.21
[SpringMVC] MVC의 Bean 정의 파일  (0) 2016.08.18
[SpringMVC] Bean 정의 파일 위치  (0) 2016.08.18
블로그 이미지

리딩리드

,