1.编写代码
?
?
class="java">package com.activiti.demo; import java.io.File; import java.util.Iterator; import java.util.LinkedList; /** * 功能:生成maven批量安装jar的语句 * @author pactera * */ public class MyTest { //批量安装jar所在目录 // public static String filePath = "D:/develop/apache-tomcat-8.0.9/apache-tomcat-8.0.9/webapps/activiti-rest/WEB-INF/lib"; public static String filePath = "E:/开发资料/工作流/activity/activiti-5.22.0/libs"; public static void main(String[] args) { LinkedList<File> linkedList = new LinkedList<>(); File f = new File(filePath); File[] file = f.listFiles(); for (int i = 0; i < file.length; i++) { linkedList.add(file[i]); } // printFile(linkedList); printFiles(linkedList); } /** * 功能:批量安装maven的本地的jar * @param args */ public static void printFile(LinkedList<File> linkedList) { String sb = "mvn install:install-file -Dfile="+filePath+"/AA.jar -DgroupId=com.activiti -DartifactId=com.activiti.AA -Dversion=1.0.0 -Dpackaging=jar"; for (Iterator<File> iterator = linkedList.iterator(); iterator.hasNext();) { File file = iterator.next(); if(file.isFile()){ String fileName = file.getName(); System.out.println(sb.replace("AA",fileName.substring(0,fileName.lastIndexOf(".")))); linkedList.remove(file); printFile(linkedList); }else{ break; } } } /** * 功能:批量引入maven的pom * @param args */ public static void printFiles(LinkedList<File> linkedList) { String sb = "<dependency><groupId>com.activiti</groupId><artifactId>com.activiti.BBB</artifactId><version>1.0.0</version><type>jar</type></dependency>"; for (Iterator<File> iterator = linkedList.iterator(); iterator.hasNext();) { File file = iterator.next(); if(file.isFile()){ String fileName = file.getName(); System.out.println(sb.replace("BBB",fileName.substring(0,fileName.lastIndexOf(".")))); linkedList.remove(file); printFiles(linkedList); }else{ break; } } } }
?2.在maven的安装bin目录上输入cmd,然后拷贝控制台语句,按下enter键即可