본문 바로가기
자바,스프링 - Java,Spring Framework

mvn 빌드시 에러 해결방법 : Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Software caused connection abort: recv failed

by devscb 2023. 4. 23.
반응형

mvn 빌드시 에러 해결방법 : Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Software caused connection abort: recv failed



아래 명령어를 사용하여 maven build를 하였으나 에러가 발생하여 해결한 사례를 공유드리고자 합니다.

mvn clean



에러메시지



발생했던 메시지는 아래와 같습니다.
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-clean-plugin/2.5/maven-clean-plugin-2.5.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.936 s
[INFO] Finished at: 2023-04-18T17:29:16+09:00
[INFO] ------------------------------------------------------------------------
[ERROR] Plugin org.apache.maven.plugins:maven-clean-plugin:2.5 or one of its dependencies could not be resolved: Failed to read artifact descriptor for org.apache.maven.plugins:maven-clean-plugin:jar:2.5: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Software caused connection abort: recv failed -> [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/PluginResolutionException

제가 일하는 곳에서 maven public repo 를 사용하지 못하게 조치가 되어 있어 발생한 문제였습니다.

해결방안 1 : repo 지정


maven plugin에 대한 repository를 지정해주는 방식입니다.
maven 프로젝트의 pom.xml 파일에 아래와 같이 pluginRepository를 지정해줍니다.
url에는 저희 회사에서 사용하는 nexus repository를 지정하였습니다.


<?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/maven-v4_0_0.xsd">
    ...
    <pluginRepositories>
     <pluginRepository>
         <id>xxx-repository</id>
      <url>http://nexus.net [원격 maven repository]</url>
     </pluginRepository>
</pluginRepositories>
...
</project>



해결방안 2 : 수동 다운로드


remote maven repo를 사용할 수 없는 오프라인 환경에서 사용하는 방식입니다.

1) jar파일을 수동으로 받습니다.
maven repository에 있는 library라면 아래 주소로 이동하여 라이브러리 이름을 검색합니다.
예를 들어, log4j를 다운받는다고 하면, 검색창에 log4j를 찾아 링크로 이동합니다.



저와 같은 maven clean plugin 2.5 문제라면,아래 링크로 이동하셔도 좋습니다.
https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-clean-plugin/2.5

링크로 이동을 한 후, view all을 클릭하여 jar파일을 다운받습니다.

 


2) 문제가 발생했던 maven local repo 위치로 이동합니다.
maven local repo의 위치는 기본적으로 c:\users\[사용자명]\.m2입니다.

여기서, 각 라이브러리의 group id, artifact id, version 폴더로 이동하여 1에서 다운받은 jar파일을 넣어줍니다.
예를 들어 log4j는 아래 위치에 jar파일을 넣어줍니다.
C:\Users\[사용자명]\.m2\repository\log4j\log4j\1.2.12
\



.(마침표) 별로 폴더 깊이가 생기며,
저와 같이 maven-clean-plugin 2.5에 문제가 생겼던 것이라면 아래 위치에 아까 다운로드 받은 jar파일을 넣어줍니다.
C:\Users\[사용자명]\.m2\repository\org\apache\maven\plugins\maven-clean-plugin\2.5


3) 다시 mvn clean 을 해보면 정상적으로 동작하게 될 것입니다.


#maven,#java,#dependency,#artifact,#repository,#메이븐,#매이븐,#자바,#디펜던시,#아티팩트

 

https://devscb.com/post/170

 

How to solve errors when building mvn: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to c

How to resolve error when building mvn: Could not transfer artifact org.apache.maven.plugins:maven-clean-plugin:pom:2.5 from/to central (https://repo.maven.apache.org/maven2): Software caused con

devscb.com

 

728x90
반응형

댓글