一方灾、資源下載地址:
1、64bit Eclipse下載地址:
2、Maven下載地址:
二议忽、Eclipse安裝:
1、解壓eclipse-jee-2019-03-R-win32-x86_64.zip
解壓目錄如下:
2十减、在eclipse中配置maven
2.1 啟動(dòng)eclipse
2.2 配置maven
Window --> Preferences-->Maven
設(shè)置User settings 選擇settings.xml,如果沒有該文件可以新建栈幸,內(nèi)容參考下方示例
settings.xml? (提取碼:v6vj)
三愤估、工程創(chuàng)建與配置
3.1 創(chuàng)建Maven工程
右下角進(jìn)度條跑完后,工程列表中有新建的工程速址,報(bào)錯(cuò)通常為缺少servlet-api的依賴玩焰,后續(xù)可以在pom.xml文件中添加依賴:
3.2 修改build path
在dianshang工程上右鍵菜單中點(diǎn)擊Build Path --> Configure Build Path
選中Libraries 頁簽,雙擊JRE System Library 進(jìn)行修改
應(yīng)用修改
工程目錄變動(dòng)如下:
3.3 修改pom文件
雙擊pom.xml文件修改芍锚,示例參考如下:
pom.xml?(提取碼:4c9p)
3.4 更新Maven工程
Alt+F5鍵調(diào)出Update Maven Project對(duì)話框昔园, 勾選 Force Uodate of Snapshots/Releases,點(diǎn)擊OK并炮,更新完畢后工程無錯(cuò)誤
3.5 添加spring框架配置文件
在src/main/resources目錄下創(chuàng)建spring.xml文件默刚,spring.xml示例如下
spring.xml?(提取碼: ytfj)
3.6 修改web.xml ,集成Spring框架
web.xml?(提取碼:vhav)
3.7 添加Spring MVC 逃魄、MyBatis荤西、日志配置文件
在src/main/resources目錄下創(chuàng)建spring-mvc.xml、spring-mybatis.xml 伍俘、jdbc.properties邪锌、log4j.properties文件
spring-mvc.xml?(提取碼:afp9)
spring-mybatis.xml?(提取碼:krmu)
jdbc.properties?(提取碼:bktn)
log4j.properties?(提取碼:xbx9)
四、使用mybatis-generator 生成MyBatis代碼
4.1 在pom.xml中添加插件及依賴
在pom.xml文件上單擊右鍵癌瘾,在彈出的菜單中選擇 Run as --> Maven Build
在goals中輸入mybatis-generator:generate觅丰,點(diǎn)擊Apply 、Close
在src/main/resources目錄創(chuàng)建generatorConfig.xml?
generatorConfig.xml?(提取碼:p6vb)
執(zhí)行mybatis-generator 妨退,在pom.xml文件上單擊右鍵舶胀,在彈出菜單中選擇Run as --> Maven build
在console中顯示構(gòu)建成功
在dianshang工程上右鍵 選擇refresh 刷新工程,查看生成的代碼