本篇文章給大家分享的是有關(guān)使用Maven怎么實現(xiàn)一個本地緩存清理小工具,小編覺得挺實用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。
創(chuàng)新互聯(lián)建站服務(wù)項目包括玉泉網(wǎng)站建設(shè)、玉泉網(wǎng)站制作、玉泉網(wǎng)頁制作以及玉泉網(wǎng)絡(luò)營銷策劃等。多年來,我們專注于互聯(lián)網(wǎng)行業(yè),利用自身積累的技術(shù)優(yōu)勢、行業(yè)經(jīng)驗、深度合作伙伴關(guān)系等,向廣大中小型企業(yè)、政府機(jī)構(gòu)等提供互聯(lián)網(wǎng)行業(yè)的解決方案,玉泉網(wǎng)站推廣取得了明顯的社會效益與經(jīng)濟(jì)效益。目前,我們服務(wù)的客戶以成都為中心已經(jīng)輻射到玉泉省份的部分城市,未來相信會繼續(xù)擴(kuò)大服務(wù)區(qū)域并繼續(xù)獲得客戶的支持與信任!
外部依賴:fastjson,commons-io,commons-lang3
import com.alibaba.fastjson.JSON; import org.apache.commons.io.FileUtils; import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import java.io.File; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.HashMap; import java.util.Map; /** * @author tjw */ public class MavenLocalRepoCleaner { /** * coordinateJson * { * "groupId1":"artifactId1:version1,artifactId2:version2...", * "groupId2":"artifactId:version,..." * } */ public static void main(String[] args) { String coordinateJson="{" + "\"top.xbynet.xxx\":\"\"" + "}"; Map<String,String> coordinateMap=JSON.parseObject(coordinateJson,HashMap.class); Path m2Repo= Paths.get(System.getProperty("user.home"),".m2","repository"); coordinateMap.entrySet().stream().forEach(v->{ String groupId=v.getKey(); groupId = groupId.replace('.', File.separatorChar); if(StringUtils.isBlank(v.getValue())){ Path dir = Paths.get(m2Repo.toString(), groupId); try { FileUtils.deleteDirectory(dir.toFile()); } catch (IOException e) { e.printStackTrace(); } }else { String[] artfactIdVers = v.getValue().split(","); for (String str : artfactIdVers) { String ver = ""; if (str.contains(":")) { ver = str.split(":")[1]; } String artfactId = str.split(":")[0]; Path dir = Paths.get(m2Repo.toString(), groupId, artfactId, ver); try { FileUtils.deleteDirectory(dir.toFile()); } catch (IOException e) { e.printStackTrace(); } } } }); } }
以上就是使用Maven怎么實現(xiàn)一個本地緩存清理小工具,小編相信有部分知識點可能是我們?nèi)粘9ぷ鲿姷交蛴玫降?。希望你能通過這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。
網(wǎng)頁題目:使用Maven怎么實現(xiàn)一個本地緩存清理小工具
網(wǎng)站URL:http://chinadenli.net/article10/pijddo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供品牌網(wǎng)站設(shè)計、服務(wù)器托管、App開發(fā)、網(wǎng)站制作、網(wǎng)站建設(shè)、手機(jī)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)