본문 바로가기

Build/Maven

08. Maven Repository

Maven 의 Repository 는 LOCAL, CENTRAL, REMOTE 로 구성된다.
 
 

Local Repository
 
말 그대로 사용자 PC 에 구축하는 Repository 이며
 
사용자가 처음으로 Maven Command 를 실행시 자동 생성된다.
 
기본 위치는 사용자 문서 폴더의 .m2 폴더를 찾아보면 된다. (ex > C:\Users\dukim\.m2\repository )
 
그리고 pom 파일에 기술된 dependencies, artifacts, JARs, plugin 들이 여기에 저장된다.
 
아래는 maven 설치 폴더의 conf/settings.xml  의 내용이며 
 
Local Repository 정보가 나와 있으며 여기서 경로를 수정할 수 있다.
 
<?xml version="1.0" encoding="UTF-8"?>
 
....
 
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  <!-- localRepository
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
 
....
 
</settings>
 

Central Repository
 
Maven 커뮤니티에 의해 제공되는 Repository 이다.
 
spring, hibernates JARs 등 개발에 많이 사용되는 정보를 가지고 있으며 
 
Local repository 에서 해당 정보를 찾지 못하면
 
central repository 에서 뒤져와 이를 local repository 에 저장한다.
 
아래 사이트에서 사용하고자 하는 JARs 를 검색하여 다운받거나
 
pom 파일에 포함시킬 정보를 얻을 수 있다.
 
 
 
 
 

 

 
 

Remote Repository
 
아래와 같이 이외의 Repository 를 구축하여 pom.xml 에 저장할 수 있다.
 
<repositories>
    <repository>
        <id>remote_lib</id>
        <url>http://download.customurl.com/lib1</url>
    </repository>
</repositories>
 
그리고 maven 명령어를 실행하면 local repository 를 뒤져서 없으면 centre 를 뒤지고
 
그래도 없으면 remote repository 를 확인해서 local repository 에 저장한다.
 
 
 
 

'Build > Maven' 카테고리의 다른 글

10. Using WARs  (0) 2020.01.23
09. pom aggregation&inheritance  (0) 2020.01.23
07. Maven plugin  (0) 2020.01.23
06. Maven phase  (0) 2020.01.23
05. Maven POM.xml  (0) 2020.01.23