티스토리 뷰

1. 개요


나는 원래 Maven 을 사용해 본 적이 없다.

기존의 시스템을 운영하고 유지보수하는 일이 주 업무였기때문에 새로운 기술을  접할 기회가 없었다.


하지만 최근 새 시스템을 운영하기 위해 인수인계를 받고 있는데, 이쪽은 Maven 으로 프로젝트를 관리하고 있었다.

이번 기회에 Maven 을 접해보고 장단점을 실제로 느껴보자.

  

메이븐은 이클립스의 플러그인들 중 하나다.

메이븐의 주요 기능은 개발자가 정의한 자바 프로젝트에서 필요로 하는 각종 라이브러리들과 이들의 종속성을 자동으로 관리해주는 것이다.

 

출처 : http://likebnb.tistory.com/128 

 

Maven 으로 신규 프로젝트를 생성하는 방법은 http://likebnb.tistory.com/128 에 잘 설명되어 있다.

 

내가 필요한건 기존에 Maven 으로 관리하던 프로젝트를 이식받는 방법이다.

아래의 과정을 따라가 보자

 

1. Import - Maven - Check out Maven Projects from SCM 선택

2. 다음 화면에서 SCM URL 을 선택할 수 없음

3. Find more SCM connector 라는 메세지를 클릭

4. Marketplace 에서 SCM 으로 Maven 용 connector 검색

5. 관련 플러그인 설치

6. Eclipse restart 후 다시 Import - Check out Maven Projects from SCM 하면 Svn URL 을 입력해줄 수 있다.

7. Svn URL 입력 후 Checking Out

 

 

그런데 Checking Out 이 진행되다가 한순간 사라져버린다..

왜 그럴까? 




 

2. 문제(1) - 네트웍 프락시 설정


지금 내 PC 에서 인터넷에 접근하기 위해서는 사내 proxy 를 무조건 타게 되어 있다.

maven 은 관련 lib update 등을 위해서는 인터넷의 maven repository 에 접근해야하고, 마찬가지로 proxy 설정이 필요하다.

maven 설치 후 C:\Documents and Settings\사용자\.m2 에 settings.xml 이 없다면 아래와 같이 만들어 주자

(이전 글에서 이클립스에 네트웍 설정으로 세팅한 proxy ip 와 동일한 값이다)

 

<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">
   <proxies>
    <proxy>
       <active>true</active>
       <protocol>http</protocol>
       <host>70.10.15.10</host>
       <port>8080</port>
     </proxy>
 </proxies>
</settings>

 





2. 문제(2) - Library Jars 인식 불가


maven project 를 check out 후 maven 을 실행해보니 에러가 난다.

자세히 보니 porm.xml 도 에러파일 표시가 나타나고,  buildpath 에서 확인해보면 maven repository 에서 일부 libs 들이 missing 상태로 되어 있다.

물론 관련 jars 들은 프로젝트의 /libs 에 별도로 저장되어 있고, check out 받았다.

 

이러때는 어떻게 해야 할까?

수동으로 찾아서 C:\Users\sds\.m2\repository 아래 디렉토리를 만들어주고 하나하나 챙겨줘야 하나?

위 방법처럼 관리할 바엔 maven을 사용하지 않는게 낫겠다.


인터넷으로는 해결 방법을 찾을 수 없어 http://socurites.com 주인장께 직접 가름침 받았다.


원인은 Maven에서 네트웍 오류 등으로 LastUpdated 실패 내역이 남아있으면 네트웍 문제가 해결된 뒤에도 정상 작동하지 않기 때문이었다.

에러로그를 확인하고 관련된 lattUpdated 파일을 찾아서 지워주자.


[에러메세지 예시]

ArtifactDescriptorException: Failed to read artifact descriptor for asm:asm:jar:3.3: ArtifactResolutionException: Failure to transfer asm:asm:pom:3.3 from http://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact asm:asm:pom:3.3 from/to central (http://repo.maven.apache.org/maven2): C:\Users\사용자\.m2\repository\asm\asm\3.3\asm-3.3.pom.ahc761bb4996fb34ed7 (지정된 파일을 찾을 수 없습니다) 


[C:\Users\사용자\.m2\repository\asm\asm\3.3\asm-3.3.pom.lastUpdated 파일 내용 ]

#NOTE: This is an internal implementation file, its format can be changed without prior notice.

#Tue Jul 09 18:43:57 KST 2013

http\://www.datanucleus.org/downloads/maven2/.error=

legacy-file\:../../local.repository/trunk/.lastUpdated=1373362730367

https\://repository.jboss.org/nexus/content/repositories/thirdparty-uploads/.lastUpdated=1373363027302

http\://maven.springframework.org/milestone/.lastUpdated=1373363037968

http\://repo.maven.apache.org/maven2/.error=Could not transfer artifact asm\:asm\:pom\:3.3 from/to central (http\://repo.maven.apache.org/maven2)\: C\:\\Users\\사용자\\.m2\\repository\\asm\\asm\\3.3\\asm-3.3.pom.ahc761bb4996fb34ed7 (\uC9C0\uC815\uB41C \uD30C\uC77C\uC744 \uCC3E\uC744 \uC218 \uC5C6\uC2B5\uB2C8\uB2E4)

file\:../../local.repository/trunk/.error=Could not transfer artifact asm\:asm\:pom\:3.3 from/to local.repository (file\:../../local.repository/trunk)\: No connector available to access repository local.repository (file\:../../local.repository/trunk) of type legacy using the available factories AsyncRepositoryConnectorFactory, WagonRepositoryConnectorFactory

http\://www.datanucleus.org/downloads/maven2/.lastUpdated=1373362730738

http\://maven.springframework.org/milestone/.error=

da39a3ee5e6b4b0d3255bfef95601890afd80709@70.10.15.10\:8080>default-http\://repo.maven.apache.org/maven2/.lastUpdated=1373362730361

https\://repository.jboss.org/nexus/content/repositories/thirdparty-uploads/.error=



해당 파일을 삭제해도 porm.xml 의 error 가 사라지지 않는다면 일부 .m2\repository\ 아래 문제가 되는 일부 lib 디렉토리를 지워버리고 새로 업데이트 해보자.

porm.xml 에 걸려있던 error 들이 한번에 해결되는 경우도 있다.



이제 Maven 실행에 문제가 없을 것이다.


추가로 Maven 은 기본적으로 /test 디렉토리를 가지고 있기 때문에 

소스코드 내에 /test 디렉토리가 없으면 역시 에러가 발생한다.

프로젝트 프로퍼티에서 /test (missing) 을 확인하고 remove 해주던지, /test 를 만들어주던지 하자   

 

728x90
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   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
글 보관함