티스토리 뷰

Maven project를 deploy 하는 과정에서 다음과 같은 오류가 발생할 수 있다. 

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.091 s
[INFO] Finished at: 2021-03-30T12:46:58+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.8.2:deploy (default-deploy) on project oing-lib: Failed to deploy artifacts: Could not transfer artifact oing-lib:jar:0.0.1-20210330.034657-1 from/to oing-snapshot-repository (https://repo.oingnexus.com/content/repositories/snapshots/): Access denied to https://repo.oingnexus.com/content/repositories/snapshots/oing-lib/0.0.1-SNAPSHOT/oing-lib-0.0.1-20210330.034657-1.jar. Error code 401, Unauthorized -> [Help 1]

BUILD FAILURE는 언제봐도 참 슬픈 단어인것 같다. 401, Unauthorized 오류라고 마지막에 나와 있다. 말 그대로 권한이 없다는것이고 무슨 권한이 없냐면 Nexus에 deploy할수 있는 권한이 없다는 것이다. Nexus에 deploy를 하기 위해서는 Nexus에 대한 계정정보가 필요하고 이는 Maven에서는 settings.xml에서 설정할 수 있다. 

 

settings.xml

settings.xml 파일이 없다면 만들어야 하고 보통은 위와 같이 C:\user\user\.m2 폴더 아래에 위치시킨다. 

 

settings.xml

<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"> 
    <servers>
        <server>
            <id>oing-repository</id>
            <username>oing</username>
            <password>ispretty</password>
        </server>
    </servers>
</settings>

settings.xml 파일을 작성하는 요령은 위와 같다. 여러가지 설정을 여기에서 해줄 수 있지만 일단은 권한 없는 문제에 대한 해결을 하는 것이므로 내가 deploy할 nexus에 대한 서버 정보를 입력을 해준다. 그리고 여기서 설정한 server id값과 동일한 값을 가진 nexus에 대한 정보는 프로젝트의 pom.xml에서 입력을 해준다. 

 

pom.xml

<repositories>
    <repository>
        <id>oing-repository</id>
        <url>https://repo.oingnexus.com/content/repositories/public/</url>
    </repository>
</repositories>

이렇게 settings.xml 에 정의한 server id 와 pom.xml 에서 정의한 repository id 를 맞춰줘야 한다. 

설정을 다 했다면 이제 settings.xml 파일을 읽을 수 있도록 이클립스에서 설정을 해줘야 한다. 

 

eclipse settings.xml 파일 설정

Window > Preferences > Maven > User Settings 에서 settings.xml 파일에 대한 설정을 할 수 있다. User Settings 부분에서 내가 만든 settings.xml 파일을 올리고 Update Settings를 눌러준다. 그럼 빌드가 될 것이고 빌드가 끝난후 다시 deploy를 해보면!

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 9.931 s
[INFO] Finished at: 2021-03-30T13:04:13+09:00
[INFO] ------------------------------------------------------------------------

위와 같은 성공화면을 볼 수 있을것이다. 

 

끝!

댓글
최근에 올라온 글
최근에 달린 댓글
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30