启动Maven文件 – 无法运行

huangapple go评论93阅读模式
英文:

Launching maven file - Unable to Run

问题

我正在尝试启动和运行Maven,并且已经完成了大部分工作(得到了帮助)。目前我可以使用'Run'按钮,但无法运行简单的程序本身。我收到以下消息:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.057 s
[INFO] Finished at: 2020-04-06T11:33:42+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [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/NoGoalSpecifiedException

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>groupId</groupId>
    <artifactId>Lesson01CipherSolution</artifactId>
    <version>1.0-SNAPSHOT</version>
    
</project>

Run/Debug Configuration:
Add New configuration -> Maven -> Locate given project Folder -> Apply/Ok
*Command line: Empty
*Profiles: Empty
*Resolve Workspace artifacts: Unchecked

是否有简单的解决方案?提前感谢。

更新:在命令行中添加'deploy'后:

[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------< groupId:Lesson01CipherSolution >-------------------
[INFO] Building Lesson01CipherSolution 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Lesson01CipherSolution ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Lesson01CipherSolution ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Lesson01CipherSolution ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\A\Desktop\S2_SoftwareVOP\Lesson 1\Lesson01CipherSolution\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ Lesson01CipherSolution ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ Lesson01CipherSolution ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ Lesson01CipherSolution ---
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ Lesson01CipherSolution ---
[INFO] Installing C:\Users\A\Desktop\S2_SoftwareVOP\Lesson 1\Lesson01CipherSolution\target\Lesson01CipherSolution-1.0-SNAPSHOT.jar to C:\Users\A\.m2\repository\groupId\Lesson01CipherSolution.0-SNAPSHOT\Lesson01CipherSolution-1.0-SNAPSHOT.jar
[INFO] Installing C:\Users\A\Desktop\S2_SoftwareVOP\Lesson 1\Lesson01CipherSolution\pom.xml to C:\Users\A\.m2\repository\groupId\Lesson01CipherSolution.0-SNAPSHOT\Lesson01CipherSolution-1.0-SNAPSHOT.pom
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ Lesson01CipherSolution ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project Lesson01CipherSolution: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [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
英文:

I am trying to get maven up and running and I got most of the things done (With help). Currently I can use the 'Run' button but I am unable to run the simple program itself. I get the following message:

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.057 s
[INFO] Finished at: 2020-04-06T11:33:42+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format &lt;plugin-prefix&gt;:&lt;goal&gt; or &lt;plugin-group-id&gt;:&lt;plugin-artifact-id&gt;[:&lt;plugin-version&gt;]:&lt;goal&gt;. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -&gt; [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/NoGoalSpecifiedException

Pom.xml

&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;
         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;
    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;

    &lt;groupId&gt;groupId&lt;/groupId&gt;
    &lt;artifactId&gt;Lesson01CipherSolution&lt;/artifactId&gt;
    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;
    
&lt;/project&gt;

Run/Debug Configuration:
Add New configuration -> Maven -> Locate given project Folder -> Apply/Ok
*Command line: Empty
*Profiles: Empty
*Resolve Workspace artifacts: Unchecked启动Maven文件 – 无法运行

Is there any simple solution to this? Thanks in advance.

Update: After adding 'deploy' to command line:

[INFO] Scanning for projects...
[INFO] 
[INFO] -------------------&lt; groupId:Lesson01CipherSolution &gt;-------------------
[INFO] Building Lesson01CipherSolution 1.0-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ Lesson01CipherSolution ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ Lesson01CipherSolution ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ Lesson01CipherSolution ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory C:\Users\A\Desktop\S2_SoftwareVOP\Lesson 1\Lesson01CipherSolution\src\test\resources
[INFO] 
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ Lesson01CipherSolution ---
[INFO] Nothing to compile - all classes are up to date
[INFO] 
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ Lesson01CipherSolution ---
[INFO] No tests to run.
[INFO] 
[INFO] --- maven-jar-plugin:2.4:jar (default-jar) @ Lesson01CipherSolution ---
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-install) @ Lesson01CipherSolution ---
[INFO] Installing C:\Users\A\Desktop\S2_SoftwareVOP\Lesson 1\Lesson01CipherSolution\target\Lesson01CipherSolution-1.0-SNAPSHOT.jar to C:\Users\A\.m2\repository\groupId\Lesson01CipherSolution.0-SNAPSHOT\Lesson01CipherSolution-1.0-SNAPSHOT.jar
[INFO] Installing C:\Users\A\Desktop\S2_SoftwareVOP\Lesson 1\Lesson01CipherSolution\pom.xml to C:\Users\A\.m2\repository\groupId\Lesson01CipherSolution.0-SNAPSHOT\Lesson01CipherSolution-1.0-SNAPSHOT.pom
[INFO] 
[INFO] --- maven-deploy-plugin:2.7:deploy (default-deploy) @ Lesson01CipherSolution ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.168 s
[INFO] Finished at: 2020-04-06T13:58:51+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project Lesson01CipherSolution: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -&gt; [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

答案1

得分: 0

为了定义将执行哪个Maven目标,您需要在“Debug/Run Configuration”的“Command line”部分中指定,就像这样:

启动Maven文件 – 无法运行

在您的示例中,您缺少命令行参数,这就是为什么会出现错误:

[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]

编辑:

请参阅Maven书中的部署部分

您需要在您的settings.xml(而不是您的pom.xml,这是不好的做法)中定义一个<repositories>元素,或者在您的pom.xml中定义一个<distributionManagement>元素,如下所示:

<distributionManagement>
    <repository>
        <uniqueVersion>false</uniqueVersion>
        <id>corp1</id>
        <name>Corporate Repository</name>
        <url>file:///home/myfolder/.m2</url>
        <layout>default</layout>
    </repository>
</distributionManagement>

请查看这个链接:https://stackoverflow.com/questions/45312708/isnt-maven-deploy-plugin-aware-of-the-pom-in-which-i-declared-it-as-a-build-plu,以及这个链接:https://stackoverflow.com/questions/37126573/failed-to-execute-goal-org-apache-maven-pluginsmaven-deploy-plugin2-7deploy-d

英文:

In order to define which maven goal will be executed you have to specify it in Debug/Run Configuration in Command line section like this:

启动Maven文件 – 无法运行

In your example you are missing command line argument and this is why you are getting an error:

[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format &lt;plugin-prefix&gt;:&lt;goal&gt; or &lt;plugin-group-id&gt;:&lt;plugin-artifact-id&gt;[:&lt;plugin-version&gt;]:&lt;goal&gt;. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -&gt; [Help 1]

EDIT:

See deploy section of the maven book.

You need to define a &lt;repositories&gt; element in your settings.xml (not in your pom.xml, that's bad) or a &lt;distributionManagement&gt; element in your pom.xml like this:

&lt;distributionManagement&gt;
    &lt;repository&gt;
        &lt;uniqueVersion&gt;false&lt;/uniqueVersion&gt;
        &lt;id&gt;corp1&lt;/id&gt;
        &lt;name&gt;Corporate Repository&lt;/name&gt;
        &lt;url&gt;file:///home/myfolder/.m2&lt;/url&gt;
        &lt;layout&gt;default&lt;/layout&gt;
    &lt;/repository&gt;
&lt;/distributionManagement&gt;

See this https://stackoverflow.com/questions/45312708/isnt-maven-deploy-plugin-aware-of-the-pom-in-which-i-declared-it-as-a-build-plu and

https://stackoverflow.com/questions/37126573/failed-to-execute-goal-org-apache-maven-pluginsmaven-deploy-plugin2-7deploy-d

huangapple
  • 本文由 发表于 2020年4月6日 17:44:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/61056949.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定