1. 點(diǎn)擊 Windows -----> Preferece
image.png
2.搜索maven 配置, 將本地下載的maven集成到STS中
-
1.選擇Installations----->Add
image.png -
2.點(diǎn)擊Driectory,選中自己本地下載的maven文件
image.png
image.png -
3.點(diǎn)擊finish
image.png -
4.選中上面加入的maven,點(diǎn)擊Apply
image.png
3.選擇User Settings 將Global Settings 和User Settings 設(shè)置成本地maven的settings.xml文件,注意看Local Repository 是否為maven的setting.xml中設(shè)置的本地倉庫路徑,若不是點(diǎn)擊Update Settings更新下,最后點(diǎn)擊 Apply and Close
image.png
4. 創(chuàng)建一個maven項目
-
File----->New----->Project 搜索maven選擇Maven Project ----->Next
image.png
-
-
勾中Create a simple project 使用骨架創(chuàng)建一個maven項目
-
-
輸入項目信息,點(diǎn)擊Finish
image.png
-
-
4 首次創(chuàng)建maven項目,需要下載相關(guān)依賴,注意Progress 是否下載完成
image.png
5. 添加一個maven依賴測試 Dependencies----->Add 填寫jar包的依賴信息,點(diǎn)擊OK
image.png
-
注意,由于STS不是自動保存,需手動保存 Ctrl+S 若本地倉庫有該依賴則需要下載,反之要會自動下載到本地倉庫,注意查看Maven Dependencies 是否有相關(guān)jar包
image.png