'2008/05'에 해당되는 글 1건
스프링 어플리케이션 컨텍스트 설정 :: 2008/05/15 23:03
스프링 프레임워크의 버전별 어플리케이션 컨텍스트 설정에 대한 간단한 샘플이다.
1. Spring 1.2에서 DTD 기반의 XML 설정을 지원한다.
2. Spring 2.0에서는 DTD 기반 설정뿐만 아니라 XML 스키마 기반의 XML 설정을 통해 보다 쉬운 컨텍스트 설정을 지원한다. 또한 클래스에서 어노테이션을 사용하여 어노테이션 기반의 컨텍스트 설정을 할 수 있다.
3. Spring 2.5에서 더 많은 XML 네임스페이스와 어노테이션이 추가되었다.
1. Spring 1.2에서 DTD 기반의 XML 설정을 지원한다.
<?xml version="1.0" encoding="UTF-8"?> <beans> <!-- ========================= DATABASE ============================ --> <bean id="propertyConfigurer" <bean id="dataSource" <!-- ========================= TRANSACTION ======================== --> <bean id="transactionManager" <!-- ========================= O/R BROKER ========================= --> <bean id="exampleBroker" <!-- ========================= DAO ================================ --> <bean id="exampleDao" class="net.java2go.dao.IBatisExampleDAOImpl"> <bean id="exampleService" class="net.java2go.service.ExampleServiceImpl"> </beans> |
2. Spring 2.0에서는 DTD 기반 설정뿐만 아니라 XML 스키마 기반의 XML 설정을 통해 보다 쉬운 컨텍스트 설정을 지원한다. 또한 클래스에서 어노테이션을 사용하여 어노테이션 기반의 컨텍스트 설정을 할 수 있다.
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" <!-- ========================= DATABASE ============================ --> <bean id="propertyConfigurer" <bean id="dataSource" <!-- ========================= TRANSACTION ======================== --> <!-- transaction --> <!--tx:annotation-driven transaction-manager="transactionManager" /--> <!-- ========================= ASPECT ============================= --> <tx:advice id="txAdvice" <bean id="loggingAspect" <aop:config> <!-- ========================= IBATIS ============================= --> <bean id="sqlMapClient" <!-- ========================= DAO ================================ --> <bean id="exampleDao" class="net.java2go.dao.IBatisExampleDAOImpl"> <bean id="exampleService" class="net.java2go.service.ExampleServiceImpl"> </beans> |
3. Spring 2.5에서 더 많은 XML 네임스페이스와 어노테이션이 추가되었다.
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" <!-- ========================= DATABASE ============================ --> <context:property-placeholder location="jdbc.properties" /> </beans> |

