◆ root-context.xml ( mybatis-spring 체크 , DB 연결 : DataSource 설정 )
페이지 정보

본문
① [Namespaces] 탭 클릭 - 5가지 항목 체크 확인
② [Source 탭] 선택후 아래 코드 삽입 , 저장
<?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:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:mybatis-spring="http://mybatis.org/schema/mybatis-spring"
xsi:schemaLocation="http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-4.3.xsd
http://mybatis.org/schema/mybatis-spring http://mybatis.org/schema/mybatis-spring-1.2.xsd
http://www.springframework.org/schema/beans http://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
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd">
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<!-- <property name="driverClassName" value="com.mysql.jdbc.Driver"></property> -->
<!-- <property name="url" value="jdbc:mysql://localhost:3306/spring"></property> -->
<property name="driverClassName" value="org.mariadb.jdbc.Driver"></property>
<property name="url" value="jdbc:mariadb://localhost:3306/spring"></property>
<property name="username" value="root"></property>
<property name="password" value="1111"></property>
</bean>
</beans>
==== 설명 ====
스프링과 MyBatis를 같이 사용하는 경우에는 주로 스프링의 설정으로 JDBC 연결을 처리하는 경우가 많다.
DataSource는 JDBC의 커넥션을 처리하는 기능을 가지고 있기 때문에 데이터베이스와 연동 작업에 반드시 필요하다.
- 이전글◆ root-context.xml ( Mybatis 연결 추가 ) 24.07.16
- 다음글▲ DataSourceTest 24.07.16
댓글목록
등록된 댓글이 없습니다.