本文整理汇总了Java中org.springframework.boot.loader.tools.JavaExecutable类的典型用法代码示例。如果您正苦于以下问题:Java JavaExecutable类的具体用法?Java JavaExecutable怎么用?Java JavaExecutable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JavaExecutable类属于org.springframework.boot.loader.tools包,在下文中一共展示了JavaExecutable类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runJar
import org.springframework.boot.loader.tools.JavaExecutable; //导入依赖的package包/类
@Test
public void runJar() throws Exception {
File target = new File("target");
File[] jarFiles = target.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return file.getName().endsWith(".jar");
}
});
assertThat(jarFiles).hasSize(1);
Process process = new JavaExecutable().processBuilder("-jar", jarFiles[0].getName()).directory(target).start();
process.waitFor(5, TimeUnit.MINUTES);
assertThat(process.exitValue()).isEqualTo(0);
String output = FileCopyUtils.copyToString(new InputStreamReader(process.getInputStream()));
assertThat(output).contains("Spring Boot Ant Example");
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:19,代码来源:SampleAntApplicationIT.java
示例2: runWithForkedJvm
import org.springframework.boot.loader.tools.JavaExecutable; //导入依赖的package包/类
@Override
protected void runWithForkedJvm(List<String> args) throws MojoExecutionException {
try {
RunProcess runProcess = new RunProcess(new JavaExecutable().toString());
Runtime.getRuntime()
.addShutdownHook(new Thread(new RunProcessKiller(runProcess)));
int exitCode = runProcess.run(true, args.toArray(new String[args.size()]));
if (exitCode != 0) {
throw new MojoExecutionException(
"Application finished with non-zero exit code: " + exitCode);
}
}
catch (Exception ex) {
throw new MojoExecutionException("Could not exec java", ex);
}
}
示例3: runJar
import org.springframework.boot.loader.tools.JavaExecutable; //导入依赖的package包/类
@Test
public void runJar() throws Exception {
File target = new File("target");
File[] jarFiles = target.listFiles(new FileFilter() {
@Override
public boolean accept(File file) {
return file.getName().endsWith(".jar");
}
});
assertThat("Number of jars", jarFiles.length, equalTo(1));
Process process = new JavaExecutable().processBuilder("-jar", jarFiles[0].getName()).directory(target).start();
process.waitFor(5, TimeUnit.MINUTES);
assertThat(process.exitValue(), equalTo(0));
String output = FileCopyUtils.copyToString(new InputStreamReader(process.getInputStream()));
assertThat(output, containsString("Spring Boot Ant Example"));
}
示例4: runWithForkedJvm
import org.springframework.boot.loader.tools.JavaExecutable; //导入依赖的package包/类
@Override
protected void runWithForkedJvm(List<String> args) throws MojoExecutionException {
try {
RunProcess runProcess = new RunProcess(new JavaExecutable().toString());
Runtime.getRuntime()
.addShutdownHook(new Thread(new RunProcessKiller(runProcess)));
runProcess.run(true, args.toArray(new String[args.size()]));
}
catch (Exception ex) {
throw new MojoExecutionException("Could not exec java", ex);
}
}
示例5: runWithForkedJvm
import org.springframework.boot.loader.tools.JavaExecutable; //导入依赖的package包/类
@Override
protected void runWithForkedJvm(List<String> args) throws MojoExecutionException {
try {
new RunProcess(new JavaExecutable().toString()).run(true,
args.toArray(new String[args.size()]));
}
catch (Exception ex) {
throw new MojoExecutionException("Could not exec java", ex);
}
}
示例6: ForkProcessCommand
import org.springframework.boot.loader.tools.JavaExecutable; //导入依赖的package包/类
ForkProcessCommand(Command command) {
super(new JavaExecutable().toString());
this.command = command;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:5,代码来源:ForkProcessCommand.java