◆ root-context.xml ( mybatis-spring 체크 , DB 연결 : DataSource 설정 ) > SPRING1

본문 바로가기
사이트 내 전체검색

SPRING1

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

페이지 정보

profile_image
작성자 관리자
댓글 0건 조회 155회 작성일 24-07-16 14:12

본문

① [Namespaces] 탭 클릭 - 5가지 항목 체크 확인 

03acdd31967b3cfaae983cdcedd38ad6_1697423527_4774.png 

 



 [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의 커넥션을 처리하는 기능을 가지고 있기 때문에 데이터베이스와 연동 작업에 반드시 필요하다. 

 

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

사이트 정보

공지사항
자유게시판
질문답변
1:1문의

 

별명 : 터푸가위
주소 : 부산시 동래구 명장로20번길 90
대표 : 박규태
메일 : dancepkt@******.com

접속자집계

오늘
73
어제
366
최대
10,760
전체
286,039
Copyright © dancePKT . All rights reserved.