VietTuts

Tự Học Lập Trình Online

  • Home
  • Java
  • Servlet
  • JSP
  • Struts2
  • Hibernate
  • Spring
  • MyBatis
  • Java WS
  • C
  • C++
  • C#
  • Python
  • PHP
  • Excel
  • VBA
  • Web
    • JavaScript
    • JQUERY
    • JSON
    • AJAX
    • CSS
    • HTML
    • HTML5
    • Node.js
    • Angular 7
  • SQL
    • MySQL
    • SQL Server
  • Misc
    • Eclipse
    • Phần mềm tiện ích
    • Cấu trúc DL&GT
    • Selenium Test

MyBatis Tuts

MyBatis - MyBatis là gì? MyBatis - file cấu hình XML MyBatis - file mapper xml MyBatis - Annotations MyBatis - Stored Procedures MyBatis - Dynamic SQL MyBatis - Hibernate

MyBatis Examples

Tạo MyBatis project trong eclipse MyBatis Example - mapper bằng file XML MyBatis Example - mapper bằng các Annotation MyBatis Example - mapper bằng file XML + interface MyBatis Example - MyBatis + Spring
1 / 3
❮ ❯

Tạo MyBatis project trong eclipse


MyBatis là gì?
Cấu hình XML

Nội dung chính

  • Tạo MyBatis project trong eclipse
    • Các bước thực hiện

Tạo MyBatis project trong eclipse

Trong bài này, chúng ta sẽ thiết lập một project sử dụng MyBatis trong eclipse bằng maven.

Các bước thực hiện

Bước 1: Mở eclipse và tạo một java project có tên mybatis-example-1.

Nhập tên java project

tao-mybatis-project-trong-eclipse-1

Click "Next" để tạo thêm thư mục resources

tao-mybatis-project-trong-eclipse-2

Nhập tên thư mục là "resources" sau đó click "Finish"

tao-mybatis-project-trong-eclipse-3

Bước 2: Convert project vừa tạo thành maven project

Click chuột phải vào project "mybatis-example-1" --> Configure --> Convert To Maven Project

tao-mybatis-project-trong-eclipse-4

Click "Finish"

tao-mybatis-project-trong-eclipse-5

Bước 3: Add các dependency cần thiết vào file pom.xml.

<dependencies>
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis</artifactId>
        <version>3.3.0</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
    </dependency>
</dependencies>

Sau khi add các dependency thì file pom.xml sẽ trông như thế này.

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>mybatis-example-1</groupId>
  <artifactId>mybatis-example-1</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  
<dependencies>
    <dependency>
        <groupId>org.mybatis</groupId>
        <artifactId>mybatis</artifactId>
        <version>3.3.0</version>
    </dependency>
    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
        <version>5.1.6</version>
    </dependency>
</dependencies>
  
  <build>
    <sourceDirectory>src</sourceDirectory>
    <plugins>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.3</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

Bước 4: Update project để tải các thư viện về local

Click chuột phải vào project "mybatis-example-1" --> Maven --> Update Project...

tao-mybatis-project-trong-eclipse-5

Sau khi update xong project, các thư viện cần thiết được tải về trong như ảnh bên dưới:

tao-mybatis-project-trong-eclipse-5

OK. Đến đây là chúng ta đã thiết lập xong project MyBatis trong Eclipse


MyBatis là gì?
Cấu hình XML

Recent Updates

Sắp Tết 2024 Rồi! - Còn bao nhiêu ngày nữa là đến tết 2024?MyBatis là gì?MyBatis - AnnotationsMyBatis - Dynamic SQLMyBatis - file cấu hình XMLMybatis - File Mapper XMLMybatis - Stored ProceduresMyBatis Example - mapper bằng AnnotationsMyBatis Example - mapper bằng file XMLMyBatis Example - mapper bằng file XML và InterfaceMyBatis Example - MyBatis + SpringSự khác nhau giữa MyBatis và HibernateTạo MyBatis project trong eclipse

VietTuts on facebook

Học Lập Trình Online Miễn Phí - VietTuts.Vn
Danh Sách Bài Học

Học Java | Hibernate | Spring
Học Excel | Excel VBA
Học Servlet | JSP | Struts2
Học C | C++ | C#
Học Python
Học SQL

Bài Tập Có Lời Giải

Bài tập Java
Bài tập C
Bài tập C++
Bài tập C#
Bài tập Python
Ví dụ Excel VBA

Câu Hỏi Phỏng Vấn

201 câu hỏi phỏng vấn java
25 câu hỏi phỏng vấn servlet
75 câu hỏi phỏng vấn jsp
52 câu hỏi phỏng vấn Hibernate
70 câu hỏi phỏng vấn Spring
57 câu hỏi phỏng vấn SQL

Scroll back to top

Copyright © 2016 VietTuts.Vn all rights reserved. | Liên hệ | Chính sách - riêng tư | sitemap.html | sitemap_index.xml