1
構建並在IDE中運行良好:從'CLI'從CLI部署maven項目?
cd /home/thufir/NetBeansProjects/HelloMaven; JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64 /home/thufir/.local/share/umake/ide/netbeans/java/maven/bin/mvn "-Dexec.args=-classpath %classpath net.bounceme.dur.hello_maven.Main" -Dexec.executable=/usr/lib/jvm/java-8-openjdk-amd64/bin/java process-classes org.codehaus.mojo:exec-maven-plugin:1.2.1:exec
Scanning for projects...
------------------------------------------------------------------------
Building HelloMaven 1.0-SNAPSHOT
------------------------------------------------------------------------
--- maven-resources-plugin:2.5:resources (default-resources) @ HelloMaven ---
[debug] execute contextualize
Using 'UTF-8' encoding to copy filtered resources.
Copying 0 resource
--- maven-compiler-plugin:2.3.2:compile (default-compile) @ HelloMaven ---
Compiling 1 source file to /home/thufir/NetBeansProjects/HelloMaven/target/classes
--- exec-maven-plugin:1.2.1:exec (default-cli) @ HelloMaven ---
Oct 21, 2017 10:21:38 AM net.bounceme.dur.hello_maven.Main getGreeting
INFO: Hello world.
------------------------------------------------------------------------
BUILD SUCCESS
------------------------------------------------------------------------
Total time: 1.994s
Finished at: Sat Oct 21 10:21:38 PDT 2017
Final Memory: 10M/153M
------------------------------------------------------------------------
但失敗:
[email protected]:~/NetBeansProjects/HelloMaven$
[email protected]:~/NetBeansProjects/HelloMaven$ mvn clean deploy -e
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building HelloMaven 1.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ HelloMaven ---
[INFO] Deleting /home/thufir/NetBeansProjects/HelloMaven/target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HelloMaven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ HelloMaven ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 1 source file to /home/thufir/NetBeansProjects/HelloMaven/target/classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ HelloMaven ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/thufir/NetBeansProjects/HelloMaven/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ HelloMaven ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ HelloMaven ---
[INFO] No tests to run.
[INFO]
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ HelloMaven ---
[INFO] Building jar: /home/thufir/NetBeansProjects/HelloMaven/target/HelloMaven-1.0-SNAPSHOT.jar
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ HelloMaven ---
[INFO] Installing /home/thufir/NetBeansProjects/HelloMaven/target/HelloMaven-1.0-SNAPSHOT.jar to /home/thufir/.m2/repository/com/mycompany/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-SNAPSHOT.jar
[INFO] Installing /home/thufir/NetBeansProjects/HelloMaven/pom.xml to /home/thufir/.m2/repository/com/mycompany/HelloMaven/1.0-SNAPSHOT/HelloMaven-1.0-SNAPSHOT.pom
[INFO]
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ HelloMaven ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 3.353 s
[INFO] Finished at: 2017-10-21T10:22:23-07:00
[INFO] Final Memory: 14M/49M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project HelloMaven: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project HelloMaven: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
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)
Caused by: org.apache.maven.plugin.MojoExecutionException: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter
at org.apache.maven.plugin.deploy.DeployMojo.getDeploymentRepository(DeployMojo.java:235)
at org.apache.maven.plugin.deploy.DeployMojo.execute(DeployMojo.java:118)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 20 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/MojoExecutionException
[email protected]:~/NetBeansProjects/HelloMaven$
最簡單可行的項目:
[email protected]:~/NetBeansProjects/HelloMaven$
[email protected]:~/NetBeansProjects/HelloMaven$ tree
.
├── nbactions.xml
├── pom.xml
└── src
├── main
│ ├── java
│ │ └── net
│ │ └── bounceme
│ │ └── dur
│ │ └── hello_maven
│ │ └── Main.java
│ └── resources
└── test
└── java
10 directories, 3 files
[email protected]:~/NetBeansProjects/HelloMaven$
這裏的pom.xml
:
[email protected]:~/NetBeansProjects/HelloMaven$
[email protected]:~/NetBeansProjects/HelloMaven$ cat 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.mycompany</groupId>
<artifactId>HelloMaven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>[email protected]:~/NetBeansProjects/HelloMaven$
如何從CLI構建和運行此項目?
類似於:
Maven: lifecycle phase to run a program?
部署目標失敗,您的IDE未嘗試運行... – f1sh
您將要嘗試部署的存儲庫添加到pom。 – bmargulies
根本不想添加或使用回購。但是,是的,正在研究'distributionManagement'標籤。 – Thufir