idae启动springboot项目会带有很长的参数,超过了cmd的长度限制,所有可以使用java语言来模拟cmd启动springboot,不受cmd字符长度限制,也可以自己定义一次启动多个springboot
command-line string limitation
public class Test {
public static void main(String[] args) throws Exception{
//放入idea中springboot的启动参数(idea下面run窗口的第一行),注意转义\,字符串加双引号,逗号分隔,替换下面的yourclasspath编译后class目录
ProcessBuilder processBuilder = new ProcessBuilder(
"/Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/bin/java","-Dfile.encoding=UTF-8","-classpath","yourclasspath", "com.a.Test"
);
processBuilder.redirectErrorStream(true);
Process process = processBuilder.start();
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while (true){
line = bufferedReader.readLine();
if (null == line) { break; }
System.out.println(line);
}
}
}