Maven專案搭建(二):Maven搭建SSM框架
上一章給大家講解了如何使用Maven搭建web專案。
這次給大家介紹一下怎麼使用Maven搭建SSM框架專案。
首先我們來看一下pom.xml的屬性介紹:
project: pom的xml根元素。 |
parent: 宣告繼承。 |
modules: 宣告聚合,該值是一個當前POM的相對目錄。使用者專案的聚合。 |
groupId: 定義當前Maven專案隸屬的實際專案。 |
artifactId: 定義實際專案中的一個Maven專案模組,一般為實際專案名稱。 |
version: 定義Maven專案當前版本。 |
groupId、artifactId、version三個屬性構成專案的座標,必須全部填寫。 |
packaging: 座標元素之一,可以不填,不填預設jar,表示專案構建成jar包;值為war表示可部署的web專案。 |
name: 名稱。 |
description: 專案描述。 |
organization: 所屬組織。 |
licenses: 許可證。 |
mailingLists: 郵件列表。 |
developers: 開發者。 |
contributors: 貢獻者。 |
issueManagement: 問題追蹤系統。 |
ciManagement: 持續整合系統。 |
scm: 版本控制系統。 |
prerequisites-->maven: 要求maven最低版本,預設值為2.0. |
build-->sourceDirectory: 主原始碼目錄。 |
build-->scriptSourceDirectory: 指令碼原始碼目錄。 |
build-->testSourceDirectory: 測試原始碼目錄。 |
build-->outputDirectory: 主原始碼輸出目錄。 |
build-->testOutputDirectory: 測試原始碼輸出目錄。 |
build-->resources-->resource: 主資源目錄。 |
build-->testResources-->testResource: 測試資源目錄。 |
build-->finalName: 輸出主構件的名稱。 |
build-->directory: 輸出目錄。 |
build-->filters-->filter: 通過properties檔案定義資源過濾屬性。 |
build-->extensions-->extension: 擴充套件Maven的核心。 |
build-->pluginManagement: 外掛管理。 |
build-->plugins-->plugin: 外掛。 |
profiles-->profile: POM Profile。 |
distributionManagement-->repository: 釋出版本部署倉庫。 |
distributionManagement-->snapshotRepository: 快照版本部署倉庫。 |
distributionManagement-->site: 站點部署。 |
repositories-->repository: 倉庫。 |
pluginRepositories-->pluginRepository: 外掛倉庫。 |
dependencies-->dependency: 依賴管理。 |
properties: Maven屬性。 |
reporting-->plugins: 報告外掛。 |
a-->b表示a元素巢狀著b元素。 |
settings.xml檔案配置:
settings: settings.xml的根元素。 |
localRepository: 本地倉庫。 |
interactiveMode: Maven是否與使用者互動,預設值為true。 |
offline: 離線模式,預設false。 |
pluginGroups-->pluginGroup: 外掛組。 |
servers-->server: 下載與部署倉庫的認證資訊。 |
mirrors-->mirror: 倉庫映象。 |
proxies-->proxy: 代理。 |
profiles-->profile: Settings Profile。 |
activeProfiles-->activeProfile: 啟用Profile。 |
Maven目錄下的conf資料夾下的settings.xml為全域性的,影響所有使用者的配置。一般建議修改c:\Users\使用者名稱\.m2\目錄下的settings.xml,屬於區域性的,只對當前目錄下的使用者有用。
Maven搭建SSM框架
好了,介紹完了pom檔案,我們就可以開始愉快的搭建SSM專案了。
1.pom檔案中新增所有jar包的依賴
2.在src/main/resources下建立配置目錄及檔案
3.在src下的main下的webapp目錄,在WEB-INF目錄下配置web.xml
4.配置mybatis清單
5.配置springmvc清單
6.配置spring清單,mybatis對映檔案放在src/main/resrouces/mybatis/mappers下
好了, Maven搭建的SSM框架內容我們告一段落了,下次繼續給大家講解如何使用Maven直接部署專案。