1. 首先下载相应的Lucene的jar包
下载地址:http://mvnrepository.com/artifact/org.apache.lucene
2. 在eclipse下编写代码生成导入命令
package com.jhkj.util;import java.io.File;public class MavenInstallJar {private String dir = "D:\\Lucene\\";private String groupId = "org.apache.lucene";String version = "5.2.1";private void outputInstallJarBatchFile() {File d = new File(dir);File[] fs = d.listFiles();for(File f : fs) {String name = f.getName().toLowerCase();String fileName = name;if(f.isFile() && name.endsWith(".jar")) {name = name.replaceAll(".jar", ""); String[] ns = name.split("-");String realName = "";for(String n : ns){realName = realName + n + "-";}realName = realName.replaceAll("-5.2.1-", "");StringBuffer sb = new StringBuffer();sb.append("mvn install:install-file -Dfile=").append(dir+fileName);sb.append(" -DgroupId=").append(groupId);sb.append(" -DartifactId=").append(realName);sb.append(" -Dversion=").append(version);sb.append(" -Dpackaging=jar");System.out.println(sb.toString());}} }public static void main(String[] args) {MavenInstallJar inst = new MavenInstallJar();inst.outputInstallJarBatchFile();}
}
生成执行命令:
3. 复制生成命令,在CMD命令行下执行