반응형

1) xml 파일에 bean 설정

<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">

<property name="driverClassName" value="org.mariadb.jdbc.Driver" />

<property name="url" value="jdbc:mariadb://localhost:3306/school" />//로컬주소:포트/데이터베이스명

<property name="username" value="root" />

<property name="password" value="****" />

</bean>



<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">

<property name="dataSource" ref="dataSource" />

<property name="typeAliasesPackage" value="com.member.school.model"/>

<property name="mapperLocations" value="classpath*:com/member/school/mappers/StudentMapper.xml" /> 

<!-- xml파일을 정해줘야한다. 혹은 에스트리크(*).xml-->

</bean>

 

2) java client connecter를 lib경로나 build path에 추가

mariadb driverclass를 읽지 못하면 mariadb java client connecter jar파일을 lib에 추가한다.

 

3) pom.xml에 mariadb를 dependency

728x90
반응형

<repositories>

    <repository>

        <id>mesir-repo</id>

        <url>http://mesir.googlecode.com/svn/trunk/mavenrepo

    </repository>

  </repositories>

<dependencies>

<!-- Spring -->

  <dependency>

    <groupId>org.springframework</groupId>

    <artifactId>spring-orm</artifactId>

    <version>3.1.1.RELEASE</version>

  </dependency>

 

  <dependency>

    <groupId>org.mybatis</groupId>

    <artifactId>mybatis</artifactId>

    <version>3.2.8</version>

  </dependency>

  <dependency>

    <groupId>org.mybatis</groupId>

    <artifactId>mybatis-spring</artifactId>

    <version>1.2.2</version>

  </dependency>

 

  <dependency>

    <groupId>com.oracle</groupId>

    <artifactId>ojdbc14</artifactId>

    <version>10.2.0.4.0</version>

  </dependency>

 

  <dependency>

            <groupId>commons-dbcp</groupId>

            <artifactId>commons-dbcp</artifactId>

            <version>1.4</version>

   </dependency> 

 

진한 글씨 2개는 꼭해줘야함

728x90

+ Recent posts