MariaDB 관련 설정

Mysql이던 Oracle이던 각각에 맞게 설정해주시면 됩니다.

xml파일의 경우 없다면 appServlelt/ 에 해당이름으로 생성후 설정해주세요.

pom.xml


<!-- MariaDB -->
<dependency>
    <groupId>org.mariadb.jdbc</groupId>
    <artifactId>mariadb-java-client</artifactId>
    <version>2.4.4</version>
</dependency>

<!-- spring jdbc driver -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-jdbc</artifactId>
    <version>4.1.4.RELEASE</version>
</dependency>

<!-- myBatis -->
<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis</artifactId>
    <version>3.2.8</version>
</dependency>

<!-- spring mybatis -->
<dependency>
    <groupId>org.mybatis</groupId>
    <artifactId>mybatis-spring</artifactId>
    <version>1.2.2</version>
</dependency>

dataSource-context.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans:beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">


    <beans:bean name="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <beans:property name="driverClassName" value="org.mariadb.jdbc.Driver"/>
        <beans:property name="url" value="jdbc:mariadb://localhost:3306/DB명"/>
        <beans:property name="username" value="ID"/>
        <beans:property name="password" value="PW"/>
    </beans:bean>

</beans:beans>

mapper-context.xml

<?xml version="1.0" encoding="UTF-8"?>

<beans:beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:beans="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <beans:bean name="sqlSession" class="org.mybatis.spring.SqlSessionFactoryBean">
        <beans:property name="dataSource" ref="dataSource"/>
        <beans:property name="mapperLocations" value="classpath*:/mapper/**/*_sql.xml"/>
    </beans:bean>

    <beans:bean name="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
        <beans:constructor-arg index="0" ref="sqlSession"/>
    </beans:bean>

</beans:beans>

web.xml

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>
            /WEB-INF/spring/*-context.xml
            /WEB-INF/spring/appServlet/*-context.xml
        </param-value>
    </context-param>