常用框架(一):spring+springMvc+mybatis+maven
阿新 • • 發佈:2018-12-06
專案說明:
(1) 本例採用 maven web 工程做例子講解
(2) 利用mybaits 提供的程式碼生成工具自動生成程式碼(dao介面,sql mapper對映檔案,pojo資料庫對映類)
(3) 資料庫用 MySQL
專案構建:
一,新建maven web 工程
網上有很多詳細的教程,初學者可以點這裡跳轉學習:eclipse建立maven工程
本例專案結構如下,待會再一步一步講解:
二,引入需要的jar包到pom.xml中,配置如下:
[html] view plain
- <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/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.maven.web</groupId>
- <artifactId>com.maven.web</artifactId>
- <packaging
- <version>0.0.1-SNAPSHOT</version>
- <name>com.maven.web Maven Webapp</name>
- <properties>
- <spring.version>4.3.0.RELEASE</spring.version>
- <jackson.version>2.6.5</jackson.version>
- <fastjson.version>1.2.23</fastjson.version>
- <mybatis.version>3.3.0</mybatis.version>
- <mybatis-spring.version>1.2.3</mybatis-spring.version>
- <mysql.connector.version>5.1.29</mysql.connector.version>
- </properties>
- <repositories>
- <repository>
- <id>spring-milestones</id>
- <name>Spring Milestones</name>
- <url>https://repo.spring.io/libs-milestone</url>
- <snapshots>
- <enabled>false</enabled>
- </snapshots>
- </repository>
- </repositories>
- <dependencies>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>javax.annotation</groupId>
- <artifactId>javax.annotation-api</artifactId>
- <version>1.2</version>
- </dependency>
- <!-- Spring -->
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-expression</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-beans</artifactId>
- <version>${spring.version}</version>
- </dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- &nbs