我是Maven的新手,并尝试使用maven-release-plugin执行发布。 运行mvn release后:准备我在控制台中收到以下信息:
[INFO]扫描项目... [INFO]
[信息] -------------------------------------------------- ---------------------- [INFO]建筑送料器1.0.3-SNAPSHOT [INFO] -------------------------------------------------- ---------------------- [INFO] [INFO] --- maven-release-plugin:2.5.2:prepare(default-cli)@ 馈线--- [INFO]恢复阶段'运行准备 - 目标' [INFO]执行目标'清理安装' ... [警告]注入错误: org.apache.maven.shared.release.exec.InvokerMavenExecutor java.lang.NoClassDefFoundError:Lorg / apache / commons / cli / Options;在 java.lang.Class.getDeclaredFields0(Native Method)at java.lang.Class.privateGetDeclaredFields(Class.java:2583)at at java.lang.Class.getDeclaredFields(Class.java:1916)at com.google.inject.spi.InjectionPoint.getInjectionPoints(InjectionPoint.java:661) 在 com.google.inject.spi.InjectionPoint.forInstanceMethodsAndFields(InjectionPoint.java:366) 在 com.google.inject.internal.ConstructorBindingImpl.getInternalDependencies(ConstructorBindingImpl.java:165) 在 com.google.inject.internal.InjectorImpl.getInternalDependencies(InjectorImpl.java:609) 在 com.google.inject.internal.InjectorImpl.cleanup(InjectorImpl.java:565) 在 com.google.inject.internal.InjectorImpl.initializeJitBinding(InjectorImpl.java:551) 在 com.google.inject.internal.InjectorImpl.createJustInTimeBinding(InjectorImpl.java:865) 在 com.google.inject.internal.InjectorImpl.createJustInTimeBindingRecursive(InjectorImpl.java:790) 在 com.google.inject.internal.InjectorImpl.getJustInTimeBinding(InjectorImpl.java:278) 在 com.google.inject.internal.InjectorImpl.getBindingOrThrow(InjectorImpl.java:210) 在 com.google.inject.internal.InjectorImpl.getProviderOrThrow(InjectorImpl.java:986) 在 com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:1019) 在 com.google.inject.internal.InjectorImpl.getProvider(InjectorImpl.java:982) 在 com.google.inject.internal.InjectorImpl.getInstance(InjectorImpl.java:1032) 在 org.eclipse.sisu.space.AbstractDeferredClass.get(AbstractDeferredClass.java:48) 在 com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:86) 在 com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:55) 在 com.google.inject.internal.ProviderInternalFactory $ 1.call(ProviderInternalFactory.java:70) 在 com.google.inject.internal.ProvisionListenerStackCallback $ Provision.provision(ProvisionListenerStackCallback.java:100) 在 org.eclipse.sisu.plexus.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:133) 在 com.google.inject.internal.ProvisionListenerStackCallback $ Provision.provision(ProvisionListenerStackCallback.java:109) 在 com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55) 在 com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68) 在 com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:47) 在 com.google.inject.internal.ProviderToInternalFactoryAdapter $ 1.call(ProviderToInternalFactoryAdapter.java:46) 在 com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1054) 在 com.google.inject.internal.ProviderToInternalFactoryAdapter.get(ProviderToInternalFactoryAdapter.java:40) 在com.google.inject.Scopes $ 1 $ 1.get(Scopes.java:59)at com.google.inject.internal.InternalFactoryToProviderAdapter.get(InternalFactoryToProviderAdapter.java:41) 在 com.google.inject.internal.InjectorImpl $ 2 $ 1.call(InjectorImpl.java:997) 在 com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1047) 在 com.google.inject.internal.InjectorImpl $ 2.注册(InjectorImpl.java:993) 在 org.eclipse.sisu.inject.LazyBeanEntry.getValue(LazyBeanEntry.java:82) 在 org.eclipse.sisu.plexus.LazyPlexusBean.getValue(LazyPlexusBean.java:51) 在java.util.AbstractMap.get(AbstractMap.java:187)at org.apache.maven.shared.release.phase.AbstractRunGoalsPhase.execute(AbstractRunGoalsPhase.java:74) 在 org.apache.maven.shared.release.phase.RunPrepareGoalsPhase.execute(RunPrepareGoalsPhase.java:44) 在 org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:234) 在 org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:169) 在 org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:146) 在 org.apache.maven.shared.release.DefaultReleaseManager.prepare(DefaultReleaseManager.java:107) 在 org.apache.maven.plugins.release.PrepareReleaseMojo.prepareRelease(PrepareReleaseMojo.java:286) 在 org.apache.maven.plugins.release.PrepareReleaseMojo.execute(PrepareReleaseMojo.java:240) 在 org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:132) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153) 在 org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116) 在 org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80) 在 org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51) 在 org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:120) 在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:347)at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:154)at org.apache.maven.cli.MavenCli.execute(MavenCli.java:582)at at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:214)at at org.apache.maven.cli.MavenCli.main(MavenCli.java:158)at at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在 sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在java.lang.reflect.Method.invoke(Method.java:497)at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289) 在 org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229) 在 org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415) 在 org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356) 引起:java.lang.ClassNotFoundException: org.apache.commons.cli.Options at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:50) 在 org.codehaus.plexus.classworlds.realm.ClassRealm.unsynchronizedLoadClass(ClassRealm.java:259) 在 org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:235) 在 org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:227) ... 67更多[INFO] -------------------------------------------------- ---------------------- [INFO] BUILD FAILURE [INFO] -------------------------------------------------- ---------------------- [INFO]总时间:1.578 s [INFO]完成时间: 2015-04-30T12:17:24 + 03:00 [INFO]最终记忆:9M / 155M [INFO] -------------------------------------------------- ---------------------- [错误]无法执行目标 org.apache.maven.plugins:行家释放小插件:2.5.2:准备 项目Feedr上的(default-cli):目标的执行default-cli org.apache.maven.plugins:maven-release-plugin:2.5.2:准备失败:A 执行时缺少必需的类 org.apache.maven.plugins:行家释放小插件:2.5.2:准备: Lorg /阿帕奇/公/ CLI /选项; [错误] -------------------------------------------------- --- [ERROR] realm = plugin> org.apache.maven.plugins:maven-release-plugin:2.5.2 [ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy [错误]网址[0] = 文件:/ C:/Users/Maya/.m2/repository/org/apache/maven/plugins/maven-release-plugin/2.5.2/maven-release-plugin-2.5.2.jar [错误]网址[1] = 文件:/ C:/Users/Maya/.m2/repository/org/apache/maven/release/maven-release-manager/2.5.2/maven-release-manager-2.5.2.jar [错误]网址[2] = 文件:/ C:/Users/Maya/.m2/repository/org/apache/maven/release/maven-release-api/2.5.2/maven-release-api-2.5.2.jar [错误]网址[3] = 文件:/ C:/Users/Maya/.m2/repository/org/eclipse/aether/aether-util/1.0.0.v20140518/aether-util-1.0.0.v20140518.jar [错误]网址[4] = 文件:/ C:/Users/Maya/.m2/repository/junit/junit/3.8.1/junit-3.8.1.jar [错误]网址[5] = 文件:/ C:/Users/Maya/.m2/repository/org/codehaus/plexus/plexus-interactivity-api/1.0-alpha-6/plexus-interactivity-api-1.0-alpha-6.jar [错误]外国进口数量:1 [错误]导入:输入[导入 来自领域ClassRealm [maven.api,parent:null]] [错误] [错误] -------------------------------------------------- ---:org.apache.commons.cli.Options [ERROR] - > [帮助1] [错误] [错误]收件人 看到错误的完整堆栈跟踪,用-e重新运行Maven 开关。 [ERROR]使用-X开关重新运行Maven以启用完全调试 日志记录。 [错误] [错误]有关错误和更多信息 可能的解决方案,请阅读以下文章:[错误] [帮助 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException
我的POM文件如下:
<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.mayacomp</groupId>
<artifactId>feeder</artifactId>
<version>1.0.3-SNAPSHOT</version>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<scm>
<developerConnection>scm:svn:http://svn01/svn/DEV/Maya/Code/feeder/tag/feeder-1.0.3</developerConnection>
<url>scm:svn:http://svn01/svn/DEV/Maya/Code/feeder/tag/feeder-1.0.3</url>
</scm>
<properties>
<java.version>1.8</java.version>
<jdk.version>1.8</jdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>net.sf.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>2.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-shared-utils</artifactId>
<version>0.7</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-archiver</artifactId>
<version>2.6</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.3</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-common-artifact-filters</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>${jdk.version}</source>
<target>${jdk.version}</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<configuration>
<archive>
<manifest>
<mainClass>com.mayacomp.feeder.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.mayacomp.feeder.App</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.2</version>
<configuration>
<tagBase>http://svn01/svn/DEV/Maya/Code/feeder/tag</tagBase>
<branchBase>http://svn01/svn/DEV/Maya/Code/feeder/branches</branchBase>
<preparationGoals>clean install</preparationGoals>
<goal>deploy</goal>
<autoVersionSubmodules>true</autoVersionSubmodules>
</configuration>
</plugin>
</plugins>
</build>
<distributionManagement>
<repository>
<id>com-mayacomp-retail-release</id>
<url>http://192.168.0.17::8080/nexus-webapp-2.11.0-02/content/repositories/com-mayacomp-retail-release</url>
</repository>
<snapshotRepository>
<id>com-mayacomp-retail-snapshot</id>
<url>http://192.168.0.17::8080/nexus-webapp-2.11.0-02/content/repositories/com-mayacomp-retail-snapshot</url>
</snapshotRepository>
</distributionManagement>
</project>
修复了pom中的scm元素:
<scm> <developerConnection>scm:svn:http://svn01/svn/DEV/Maya/Code/Feeder/trunk</developerConnection>
<url>scm:svn:http://svn01/svn/DEV/Maya/Code/Feeder/trunk</url>
</scm>
答案 0 :(得分:2)
不要将maven-assembly-plugin
,maven-shared-utils
,maven-common-artifact-filters
,maven-release-plugin
等内容定义为依赖项。这些是您不需要定义为依赖项的插件。它们与您的生产代码无关。此外,您不需要在maven-release-plugin配置中定义tagBase
,branchBase
和preparationGoals
以及goal
,因为它看起来像您有默认的文件夹布局svn存储库。
最重要的部分是您需要更改scm条目以表示主干和 NOT 标记,如果您正在使用SNAPSHOT,则这是默认标记。