Запуск файла maven - Невозможно запустить - PullRequest
0 голосов
/ 06 апреля 2020

Я пытаюсь получить Maven и работает, и я сделал большинство вещей (с помощью). В настоящее время я могу использовать кнопку «Выполнить», но не могу запустить саму простую программу. Я получаю следующее сообщение:

[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>

Запуск / отладка конфигурации: Добавить новую конфигурацию -> Maven -> Найти папку данного проекта -> Применить / ОК * Командная строка: пусто * Профили: пусто * Разрешить артефакты рабочей области: не проверено enter image description here

Есть ли какое-нибудь простое решение для этого? Заранее спасибо.

Обновление: после добавления '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_Software\1VOP\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_Software\1VOP\Lesson 1\Lesson01CipherSolution\target\Lesson01CipherSolution-1.0-SNAPSHOT.jar to C:\Users\A\.m2\repository\groupId\Lesson01CipherSolution\1.0-SNAPSHOT\Lesson01CipherSolution-1.0-SNAPSHOT.jar
[INFO] Installing C:\Users\A\Desktop\S2_Software\1VOP\Lesson 1\Lesson01CipherSolution\pom.xml to C:\Users\A\.m2\repository\groupId\Lesson01CipherSolution\1.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 -> [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 Ответ

1 голос
/ 06 апреля 2020

Чтобы определить, какая цель maven будет выполнена, вы должны указать ее в разделе «Отладка / запуск конфигурации» в разделе «Командная строка» следующим образом:

enter image description here

В вашем примере вам не хватает аргумента командной строки, и именно поэтому вы получаете сообщение об ошибке:

[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 .

Вам необходимо определить элемент <repositories> в вашем settings.xml (не в вашем pom.xml, это плохо) или элемент <distributionManagement> в вашем pom.xml следующим образом:

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

См. Это Разве maven-deploy-plugin не знает о pom, в котором я объявил его как плагин для сборки? и

Не удалось выполнить цель org . apache .maven.plugins: maven-deploy-plugin: 2.7: развернуть default-deploy в проекте

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...