我有一个简单的project,它现在什么也不做,只是一个简单的Spring Boot 2
应用程序,它应该使用java 9
。
当我在hero-journey
文件夹上运行mvnw clean package
时,我收到此错误
ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.0.M5:repackage (default) on project hero-journey-web: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.0.0.M5:repackage failed.: RuntimeException ->
[Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.0.0.M5:repackage (default) on project hero-journey-web: Execution default of goal org.springframework.boot:spring-boot-maven-plugin
:2.0.0.M5:repackage failed.
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:154)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:146)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:309)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:194)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:107)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:993)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:345)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:191)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
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)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.apache.maven.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:39)
at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:122)
at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:50)
Caused by: org.apache.maven.plugin.PluginExecutionException: Execution default of goal org.springframework.boot:spring-boot-maven-plugin:2.0.0.M5:repackage failed.
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:145)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 27 more
Caused by: java.lang.RuntimeException
at org.springframework.asm.ClassVisitor.visitModule(ClassVisitor.java:148)
at org.springframework.asm.ClassReader.readModule(ClassReader.java:762)
at org.springframework.asm.ClassReader.accept(ClassReader.java:663)
at org.springframework.asm.ClassReader.accept(ClassReader.java:527)
at org.springframework.boot.loader.tools.MainClassFinder.createClassDescriptor(MainClassFinder.java:267)
at org.springframework.boot.loader.tools.MainClassFinder.doWithMainClasses(MainClassFinder.java:223)
at org.springframework.boot.loader.tools.MainClassFinder.findSingleMainClass(MainClassFinder.java:203)
at org.springframework.boot.loader.tools.Repackager.findMainMethod(Repackager.java:365)
at org.springframework.boot.loader.tools.Repackager.findMainMethodWithTimeoutWarning(Repackager.java:354)
at org.springframework.boot.loader.tools.Repackager.buildManifest(Repackager.java:325)
at org.springframework.boot.loader.tools.Repackager.repackage(Repackager.java:255)
at org.springframework.boot.loader.tools.Repackager.repackage(Repackager.java:248)
at org.springframework.boot.loader.tools.Repackager.repackage(Repackager.java:193)
at org.springframework.boot.maven.RepackageMojo.repackage(RepackageMojo.java:221)
at org.springframework.boot.maven.RepackageMojo.execute(RepackageMojo.java:208)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
... 28 more
[ERROR]
[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/PluginExecutionException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :hero-journey-web
字符串
除了RuntimeException
和在类解析时发生的一些事情(看起来)之外,它没有提供任何有关原因的特定信息。mvn -version
的外观如下所示
Apache Maven 3.5.0
Maven home: L:\installed\apache-maven-3.5.0\bin\..
Java version: 9, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk-9
型
问题出在哪里?
我的主pom.xml
如下所示
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.lapots.breed.hero.journey</groupId>
<artifactId>hero-journey</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>pom</packaging>
<name>hero-journey</name>
<description>Start the journey towards the greatest powers</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.0.M5</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<modules>
<module>hero-journey-web</module>
</modules>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>9</java.version>
</properties>
<distributionManagement>
<repository>
<id>google-drive-repository</id>
<url>file://L:/google-drive/m2-artifactory/mvn-releases</url>
</repository>
<snapshotRepository>
<id>google-drive-snapshot</id>
<url>file://L:/google-drive/m2-artifactory/mvn-snapshots</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>google-drive-releases</id>
<url>file://L:/google-drive/m2-artifactory/mvn-releases</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>google-drive-snapshots</id>
<url>file://L:/google-drive/m2-artifactory/mvn-snapshots</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>spring-snapshots</id>
<name>Spring Snapshots</name>
<url>https://repo.spring.io/snapshot</url>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
<pluginRepository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</project>
型
我的子项目pom.xml
如下所示
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.lapots.breed.hero.journey</groupId>
<artifactId>hero-journey</artifactId>
<version>0.0.1-SNAPSHOT</version>
</parent>
<artifactId>hero-journey-web</artifactId>
<description>Hero Journey - web application</description>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
型
5条答案
按热度按时间z18hc3ub1#
似乎我遇到了现有的issue,所以我使用@wilkinsona提供的解决方案来解决它。我添加了
configuration
和mainClass
,项目成功构建。字符串
ntjbwcob2#
我也有类似的问题。
字符串
我的主pom.xml看起来像这样
型
我把
<plugins>
标记在<pluginManagement>
的大小按照下面的代码,我的问题解决了。型
3htmauhk3#
我在pom.xml中添加了一个configuration(标签),并引用了main class。这就解决了这个问题。
字符串
laik7k3q4#
你可以使用这种方式。你添加一个配置到pom,但这种方式只适用于编译器。它不工作真实的世界。如果你想使用.jar或.war。它不会工作。**你必须在java文件下添加com.lapots.breed.hero.journey文件。**然后它总是工作
tp5buhyn5#
在我们的例子中,我们有微服务(Sping Boot App),公共代码被分成库。库也是作为Sping Boot App构建的,后来我们删除了资源和测试文件夹。但是因为我们不想要主App.java,我们也删除了它。那时我们无法构建应用程序,但是我们已经在
<pluginManagement>
下有了spring-boot-maven-plugin
,但是仍然不能在STS4.15.3.RELEASE
中做clean install
。所以我们在同一个plugin
中添加了一个额外的配置。字符串
这个很好用