myeclipse下使用maven搭建SSM(spring、springmvc、mybatis)框架
阿新 • • 發佈:2019-02-12
轉自:http://blog.csdn.net/u012767369/article/details/70209400
MyEclipse配置Maven
1、在本地建立一個資料夾MavenRepository,並在MavenRepository資料夾下建立資料夾repo
2、進入Maven解壓後的資料夾,進入conf資料夾,將settings.xml檔案複製到上一步建立的MavenRepository資料夾下
3、開啟MavenRepository資料夾下的settings.xml檔案,找到localRepository標籤,此時是被註釋掉的,我們解除註釋,然後配置步驟1中的repo路徑,如E:\MavenRepository\repo
4、在MyEclipse中的Perferences進行如下配置,新增自己的Maven
5、User Settings設定為之前修改過的setting.xml
6、File->New->others,搜尋maven,如果看到有Maven Project則代表配置成功
MyEclipse使用maven建立web專案
2、按照上面教程,即可創建出一個Maven專案,專案結構如下圖
3、將JRE版本設定為1.7,可使用預設的或者自己匯入
4、此時index.jsp會報以下錯誤
在pom.xml檔案的dependencies節點下新增如下程式碼即可,新增完後,會下載對應的jar包
5、右鍵專案,選擇Properties,進行如下配置
搭建Spring+SpringMVC+Mybatis框架
1、Maven引入專案用到的jar包,修改pom.xml後儲存會自動下載,存放在之前配置的本地倉庫中,即:E:\MavenRepository\repo
資料夾pom.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 | <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.chillax</groupId> <artifactId>Maven_Project</artifactId> <packaging>war</packaging> <version>0.0.1-SNAPSHOT</version> <name>Maven_Project Maven Webapp</name> <url>http://maven.apache.org</url> <!-- 用來設定版本號 --> <properties> <srping.version>4.0.2.RELEASE</srping.version> <mybatis.version>3.2.8</mybatis.version> <slf4j.version>1.7.12</slf4j.version> <log4j.version>1.2.17</log4j.version> </properties> <!-- 用到的jar包 --> <dependencies> <!-- 單元測試 --> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>4.11</version> <!-- 表示開發的時候引入,釋出的時候不會載入此包 --> <scope>test</scope> </dependency> <!-- java ee包 --> <dependency> <groupId>javax</groupId> <artifactId>javaee-api</artifactId> <version>7.0</version> </dependency> <!-- spring框架包 start --> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-test</artifactId> <version>${srping.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-core</artifactId> <version>${srping.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-oxm</artifactId> <version>${srping.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-tx</artifactId> <version>${srping.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-jdbc</artifactId> <version>${srping.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-aop</artifactId> <version>${srping.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>${srping.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-context-support</artifactId> <version>${srping.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-expression</artifactId> <version>${srping.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-orm</artifactId> <version>${srping.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-web</artifactId> <version>${srping.version}</version> </dependency> <dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>${srping.version}</version> </dependency> <!-- spring框架包 end --> <!-- mybatis框架包 start --> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>${mybatis.version}</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.2.2</version> </dependency> <!-- mybatis框架包 end --> <!-- 資料庫驅動 --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.35</version> </dependency> <!-- 匯入dbcp的jar包,用來在applicationContext.xml中配置資料庫 --> <dependency> <groupId>commons-dbcp</groupId> <artifactId>commons-dbcp</artifactId> <version>1.4</version> </dependency> <!-- jstl標籤類 --> <dependency> |