IT박스

maven 명령 실행 후 "지정한 목표를 실행하려면 프로젝트가 필요하지만이 디렉토리에 POM이 없습니다"오류

itboxs 2020. 8. 13. 08:06
반응형

maven 명령 실행 후 "지정한 목표를 실행하려면 프로젝트가 필요하지만이 디렉토리에 POM이 없습니다"오류


나는 pom.xml안으로 C:\Users\AArmijos\Desktop\Factura Electronica\MIyT\componentes-1.0.4\sources\pom.xml있고 나는 실행했다.

mvn install:install-file -DgroupId=es.mityc.jumbo.adsi -DartifactId=xmlsec-1.4.2-ADSI -Dversion=1.0 -Dpackaging=jar -Dfile=C:\Users\AArmijos\Desktop\Factura Electronica\MIyT\componentes-1.0.4\core\xmlsec-1.4.2-ADSI-1.0.jar

그러나 아래 오류가 반환되었습니다.

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.310s
[INFO] Finished at: Thu May 02 16:48:29 COT 2013
[INFO] Final Memory: 2M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM
 in this directory (C:\Users\AArmijos). Please verify you invoked Maven from the
 correct directory. -> [Help 1]

누군가 실패 이유를 설명 할 수 있습니까?


이 링크가 도움이되었습니다 : https://stackoverflow.com/a/11199865/1307104

다음과 같이 모든 매개 변수에 따옴표를 추가하여 명령을 편집합니다.

mvn install:install-file "-DgroupId=org.mozilla" "-DartifactId=jss" "-Dversion=4.2.5" "-Dpackaging=jar" "-Dfile=C:\Users\AArmijos\workspace\componentes-1.0.4\deps\jss-4.2.5.jar"

작동했습니다.


Windows에서이 문제가 발생하고 위의 방법 중 어느 것도 작동하지 않은 경우 cmd.exe에서 실행 해보십시오. PowerShell을 통해 이러한 명령을 실행하면 매번 설치가 실패했습니다.


내가 염려하는 한 Windows에서는 모든 매개 변수를 따옴표로 묶어야합니다.

따라서 maven webapp archetype을 생성하려면 다음과 같이하십시오.

전제 조건 :

  1. Maven이 설치되어 있고 PATH 환경 변수에 있는지 확인하십시오.

어떻게:

  1. Windows PowerShell 열기
  2. mkdir MyWebApp
  3. cd MyWebApp
  4. mvn archetype : generate "-DgroupId = com.javan.dev" "-DartifactId = MyWebApp" "-DarchetypeArtifactId = maven-archetype-webapp" "-DinteractiveMode = false"

여기에 이미지 설명 입력

참고 : 이것은 Windows 10 powershell에서만 테스트되었습니다.


Windows 사용자를위한 답변을 하나 더 추가합니다. 이것으로 문제가 해결되지 않으면.

space전후에 추가하지 마십시오.=

-DgroupId= com.company.module //Wrong , Watch the space after the equal to 
-DgroupId=com.company.module //Right 

"-DgroupId = com .."과 같이 모든 것을 큰 따옴표 안에 넣는 것이 좋습니다. 이렇게하면 임의의 오류가 아닌 정확한 오류가 발생합니다.

이상하게도 maven은 문서에서 이것을 언급하는 것을 신경 쓰지 않습니다.


In my case, its because I copied pasted the command from the browser and it turned out that the dash was not the ASCII dash, just delete and type the dash again.

http://www.toptip.ca/2017/04/maven-most-weird-error-causing-failure.html


1.create a lib folder in your project file,

2.copy your jarFiles to the lib folder

3.right click on to your jarFile go to build path>Add to build path (now your jar file is part of your refrerenced libraries )

4.open command prompt and navigate to your project directory and write

mvn install: install-file "-Dfile=<yourJarFileName>.jar" "-DgroupId=<yourGroupID>" "-DartifactId=<yourArtifactId>" "-Dversion=<yourVersion>" "-Dpackaging=jar" 

6.Rebuild your local repository index by opening in eclipse- go to window>show view>other>maven>maven Repositories. Right click on local Repositores and hit "RebuildIndex"

5.open your pom.xml file and add your dependency

    <dependency>
        <groupId><yourGroupID></groupId>
        <artifactId><yourArtifactId></artifactId>
        <version><yourVersion></version>
    </dependency>

and run

mvn clean
mvn compile 
mvn test 

Changing mvn clean to mvn clean --file *.pom fixed this issue for me.


On Windows, I got this error when running under a non-administrator command prompt. When I ran this as administrator, the error went away.


I got this error suddenly in Netbeans (but it worked from the command line) and it turns out some other program had changed the default directory of the command prompt. And because Netbeans runs "cmd /c" when invoking maven, it starts in an incorrect directory.

Check out in Regedit the value for

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\Autorun  

If it has been set, you probably should remove it to fix the problem. (1)

(I landed here when trying to resolve this issue, might not be 100% applicable to the current question - but might help others)

(1) Changing default startup directory for command prompt in Windows 7


  • The execution of maven command required pom.xml file that contains information about the project and configuration details used by Maven to build the project. It contains default values for most projects.

  • Make sure that porject should contains pom.xml at the root level.


Add the Jenkinsfile where the pom.xml file has present. Provide the directory path on dir('project-dir'),

Ex:

node {

    withMaven(maven:'maven') {

        stage('Checkout') {
            git url: 'http://xxxxxxx/gitlab/root/XXX.git', credentialsId: 'xxxxx', branch: 'xxx'
        }

        stage('Build') {

            **dir('project-dir') {**
                sh 'mvn clean install'

                def pom = readMavenPom file:'pom.xml'

                print pom.version
                env.version = pom.version
            }
        }
    }
}

Please run it from the directory where POM.XML resides.


"The goal you specified requires a project to execute": The answer is in your question. I faced the same issue. Run the "mvn command" within the project folder, Also make sure sure its a maven configured project and hence contains the "POM.xml" file and you should be good to go!

참고 URL : https://stackoverflow.com/questions/16348459/error-the-goal-you-specified-requires-a-project-to-execute-but-there-is-no-pom

반응형