03.root.xml
Servlet-context.xml 분석하기
web.xml에 정의된 contextloaderlistener가 로딩하는 자바빈을 정의 한다 (부모 컨텍스트를 정의한다)
dispatcher서블릿이 로딩하는 자바빈은 자식 컨텍스트
<?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"
xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
xsi:schemaLocation="http://mybatis.org/schema/mybatis-spring
http://mybatis.org/schema/mybatis-spring-1.2.xsd
http://www.springframework.org/schema/beans
https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.SimpleDriverDataSource">
<property name="driverClass" value="${driver}"></property>
<property name="url" value="${url}"></property>
<property name="username" value="${username}"></property>
<property name="password" value="${password}"></property>
</bean>
<bean id="propertyPlaceholderConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" value="/WEB-INF/mybatis/db.properties"></property>
</bean>
데이터베이스 연결 정보 분리하기
<!-- navermail설정 -->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="smtp.naver.com"/> <!-- 메이서버 호스트 -->
<property name="port" value="587"/> <!-- 메이서버 포트번호 -->
<property name="username" value="###"/> <!-- 자신의 이메일 아이디 -->
<property name="password" value="###"/> <!-- 자신의 비밀번호 -->
<!-- 보안연결 SSL과 관련된 설정 -->
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">true</prop>
<prop key="mail.smtp.starttls.enable">true</prop>
<prop key="mail.smtps.checkserveridentity">true</prop>
<prop key="mail.smtps.ssl.trust">*</prop>
<prop key="mail.smtp.ssl.protocols">TLSv1.2</prop>
<prop key="mail.debug">true</prop>
<prop key="mail.smtp.socketFactory.class">javax.net.ssl.SSLSocketFactory</prop>
</props>
</property>
</bean>
SMTP를 사용하기 위한 설정
SSL: 데이터를 암호화하여 인터넷 연결 보안을 유지
<bean id="sqlSessionFactoryBean" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="configLocation" value="/WEB-INF/mybatis/config.xml"></property>
</bean>
데이터베이스와의 연결과 SQL의 실행에 대한 모든 것을 가진 가장 중요한 객체이다.
DataSource를 참조하여 MyBatis와 오라클 서버를 연동시켜준다.
<mybatis-spring:scan base-package="com.supermm.mapper"/>
<context:component-scan base-package="com.supermm.model"></context:component-scan>
<context:component-scan base-package="com.supermm.service"></context:component-scan>
</beans>
어디서 부터 어디까지 스캔을 할것인지를 정해준다.
빈으로 사용될 클래스를 스캔하여 빈으로 등록 시켜준다.
댓글남기기