java - 从命令行打包 Spring Boot 2.0.0.M5 应用程序时出错

标签 java spring maven spring-mvc spring-boot

我有一个 Spring Boot 2.0.0.M5 应用程序。使用 quartz ,我使用 Spring Tool Suite 版本创建:3.9.0.RELEASE

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-quartz</artifactId>
</dependency>

但是我在构建它时遇到错误,但是当我从命令行运行命令mvn clean package时,我不知道错误来自哪里

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.20.1:test (default-test) on project telefonicaUtils: There are test failures.
[ERROR] 
[ERROR] Please refer to /Users/lopes/Documents/workspace-sts-3.9.0.RELEASE/telefonicaUtils/target/surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date]-jvmRun[N].dump, [date].dumpstream and [date]-jvmRun[N].dumpstream.
[ERROR] The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /Users/lopes/Documents/workspace-sts-3.9.0.RELEASE/telefonicaUtils && /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/bin/java -jar /Users/lopes/Documents/workspace-sts-3.9.0.RELEASE/telefonicaUtils/target/surefire/surefirebooter5299870482700724545.jar /Users/lopes/Documents/workspace-sts-3.9.0.RELEASE/telefonicaUtils/target/surefire 2017-10-27T11-43-54_756-jvmRun1 surefire7195528782456466016tmp surefire_03680109476808337424tmp
[ERROR] Process Exit Code: 0
[ERROR] org.apache.maven.surefire.booter.SurefireBooterForkException: The forked VM terminated without properly saying goodbye. VM crash or System.exit called?
[ERROR] Command was /bin/sh -c cd /Users/lopes/Documents/workspace-sts-3.9.0.RELEASE/telefonicaUtils && /Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home/jre/bin/java -jar /Users/lopes/Documents/workspace-sts-3.9.0.RELEASE/telefonicaUtils/target/surefire/surefirebooter5299870482700724545.jar /Users/lopes/Documents/workspace-sts-3.9.0.RELEASE/telefonicaUtils/target/surefire 2017-10-27T11-43-54_756-jvmRun1 surefire7195528782456466016tmp surefire_03680109476808337424tmp
[ERROR] Process Exit Code: 0
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:686)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.fork(ForkStarter.java:535)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:280)
[ERROR] at org.apache.maven.plugin.surefire.booterclient.ForkStarter.run(ForkStarter.java:245)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeProvider(AbstractSurefireMojo.java:1124)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.executeAfterPreconditionsChecked(AbstractSurefireMojo.java:954)
[ERROR] at org.apache.maven.plugin.surefire.AbstractSurefireMojo.execute(AbstractSurefireMojo.java:832)
[ERROR] at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
[ERROR] at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)
[ERROR] at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
[ERROR] at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
[ERROR] at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
[ERROR] at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
[ERROR] at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
[ERROR] at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
[ERROR] at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR] at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR] at java.lang.reflect.Method.invoke(Method.java:498)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
[ERROR] at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

也是我在应用程序中进行的唯一测试。是这个吗:

@RunWith(SpringRunner.class)
@SpringBootTest
public class TelefonicaUtilsApplicationTests {

    @Test
    public void contextLoads() {
    }

}

但只做mvn clean它工作正常

我还尝试了 mvn clean install -XX:-UseLoopPredicate 并出现以下错误:

[ERROR] No plugin found for prefix 'X' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/lopes/.m2/repository), spring-snapshots (https://repo.spring.io/snapshot), spring-milestones (https://repo.spring.io/milestone), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
org.apache.maven.plugin.prefix.NoPluginFoundForPrefixException: No plugin found for prefix 'X' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/Users/lopes/.m2/repository), spring-snapshots (https://repo.spring.io/snapshot), spring-milestones (https://repo.spring.io/milestone), central (https://repo.maven.apache.org/maven2)]
    at org.apache.maven.plugin.prefix.internal.DefaultPluginPrefixResolver.resolve(DefaultPluginPrefixResolver.java:93)
    at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.findPluginForPrefix(MojoDescriptorCreator.java:266)
    at org.apache.maven.lifecycle.internal.MojoDescriptorCreator.getMojoDescriptor(MojoDescriptorCreator.java:220)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:103)
    at org.apache.maven.lifecycle.internal.DefaultLifecycleTaskSegmentCalculator.calculateTaskSegments(DefaultLifecycleTaskSegmentCalculator.java:83)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:89)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:307)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:193)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:106)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:862)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:286)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:197)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)

我也尝试将其添加到 pom.xml 中,但出现相同的错误

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>
        <argLine>-Xmx1024m -XX:MaxPermSize=256m</argLine>
    </configuration>
</plugin>

这是 java 版本:

java version "1.8.0_151"
Java(TM) SE Runtime Environment (build 1.8.0_151-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.151-b12, mixed mode)

最佳答案

日志的问题似乎与maven-surefire-plugin无关。虽然从日志(jdk1.8.0_77)和明确指定的java版本(1.8.0_151)来看,似乎存在不一致。

您应该更新计算机的 Maven 配置以使用最新的 Java 版本。

<小时/>

补充一下,命令mvn clean可以正常执行,因为它不涉及编译/执行代码。

来自Maven - Introduction to the lifecycle

the clean lifecycle handles project cleaning

本质上

remove all files generated by the previous build

<小时/>

执行下一个mvn clean install -XX:-UseLoopPredicate命令,失败,因为maven命令行上没有-XX这样的参数标志。您应该看看 Is there a way to pass jvm args via command line to maven?看来你在那里受审的目的是。

关于java - 从命令行打包 Spring Boot 2.0.0.M5 应用程序时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46972246/

相关文章:

java - android 如何以及何时使用 getSupportFragmentManager (新手很困惑)

spring - 过期key触发事件-Spring data Redis

java - spring-hibernate事务不回滚

java - 如何绕过 Maven 的企业防火墙/代理

java - JUnit 正在运行最终测试?

java - 我的比较器没有正确排序这个 PriorityQueue?

Java - HBase 客户端停留在 session 建立完成

java - JFreeChart CategoryPlot 覆盖类别

java - IntelliJ maven 项目生成的源未获取(仅部分)