티스토리 뷰
내부망 및 폐쇄망에서 Maven으로 설정하게 되면 라이브러리를 받을수없기때문에 개발 이나 유지보수를 할수없다.
외부인터넷에 접속할수없을경우에는 자체 Repository를 설치하여 해당 pc만 외부네트워크를 켜거나
필요한 해당 라이브러리를 저장매체를 이용해서 옴겨서 Repository에 등록하여 사용하는 방법을 사용하여야한다.
Nexus 로 Repository를 관리할수있다.
다운로드
nexus 다운로드 사이트에서 다운로드
Maven과 연동해야 하므로 nexus-2.13.0-01-bundle.tar.zip을 다운받았다
http://www.sonatype.com/download-oss-sonatype
실행
원하는 디렉토리에 다운로드한 zip 파일을 압축해제하면
nexus-버전, sonatype-work 폴더가 생성된다
nexus-2.13.0-01\bin\jsw 디렉토리로 가서
자신에게 맞는 운영체제의 폴더로 들어간 후 (예: windows-x86-64)
1. install-nexus.bat 실행
2. start-nexus 실행
※ war 파일로 설치해서 tomcat이나 자신이 사용하는was에 올려서 바로 사용할 수도 있고 nexus를 바로 실행 할 수도 있다(junit이라는 놈 덕분에) 그러나 나는 바로 실행!
Reference
https://www.lesstif.com/pages/viewpage.action?pageId=13631508
http://www.egovframe.go.kr/wiki/doku.php?id=egovframework:dev2:dep:nexus
사용
로그인을 진행한다. 초기 id와 비번은 admin /admin123
보안을 위해 비밀번호는 초기화 한다
사용하기 전 알아야하는 개념 1 : Repository Type
1. Hosted : 기본 Type으로서 회사 내에서 개발한 jar 파일 또는 회사에서 제품개발을 하기 위해서 구입한 3rd party의 jar 파일을 관리하는 Repository가 이에 속합니다. Nexus에서 기본적으로 제공하는 Hosted Type Repository는 Snapshots(사내 개발용 repository), Releases(사내 제품 repository), 3rd party를 제공합니다.
2. Proxy : Global Repository처럼 외부 Repository에 대해서 proxy 역할을 합니다. maven의 Central Repository는 매우 느리고, 최신 버전이 올라오는 데 굉장히 오래 걸립니다. 그래서 jboss, springsource 등에서 별도의 maven repository를 구축하여 운영하고 있습니다. 이런 경우에 각 개발자들이 해당 maven repository에 대한 설정을 각각 할 수 있기 때문에 Remote Repository를 외부 오픈소스에 대한 Proxy 서버로서의 역할을 수행할 수 있습니다. Nexus에서 기본적으로 제공하는 Proxy Type Repository는 Google Code, java.net, Maven Central이 있습니다.
3. Virtual : 서로 다른 타입의 Repository에 대해서 adapter 역할을 합니다. 현재 Nexus는 maven1 repository와 maven2 repository에 대한 atapter 역할만 제공하고 있습니다.
4. Group : 여러 개의 Repository를 하나로 묶어주는 역할을 합니다. |
사용하기전 알아야하는 개념 2 : Repository
① Snapshots : 빌드등 수시로 릴리즈 되는 바이너리를 배포 하는 장소 ② Releases : 정식 릴리즈를 통해서 배포되는 바이너리를 저장하는 저장소 ③ 3rd party : 벤더등에서 배포하는 (Oracle,IBM등) 바이너리를 저장해놓는 장소로 특정 솔루션등을 사용할때, 딸려 오는 라이브러리등을 여기에 놓고 사용한다 ④ Proxy Repository : 원격에 원본 repository가 있는 경우, Local에 캐쉬 용도로 사용한다. ⑤ Virtual Repository : Repository Group은 몇 개의 repository를 하나의 repository로 묶어서 단일 접근 URL을 제공한다. |
개념 정리
- Central의 경우 maven repository에서 라이브러리 목록을 index 캐싱 해오고,
pom.xml을 통해 실행을 하는 경우에 proxy를이용해 라이브러리를 다운받아 놓는다
- third party repository는 사용자가가 제작한 라이브러리나 벤더에서 제공하는 라이브러리를 저장할 수 있다.
- public repository는 central 라이브러리와 3rd party 라이브러리를 통합하여 제공한다. 따라서 pom.xml에 public 라이브러리를 등록하면 모든 라이브러리를 접근하여 사용할 수 있게 된다.
1. maven lib 설정
1-1)
repositories tab에서 > central 클릭 > configuration > Download Remote Indexes : True 설정 > Save
1-2)
Browse Index에서 cache된 내용 확인 > pom.xml 실행 > Browse Storage에서 다운된 lib 확인
1-3) 진행중인 작업확인
Administration > Scheduled Tasks 에서 작업을 클릭하여 진행상태 확인
2. custom lib 등록
2-1) Repositories > 3rd party Repositories > Artifact Upload > GAV Definition
1. pom.xml 존재 시
GAV Definition > From POM > pom.xml 경로 선택
2. pom.xml 이 없는경우
GAV Definition > GAV Parameters > Group, Aritifact, Version, Packaging 입력 및 설정
2-2)
Select Artifact(s) Upload > jar 파일 선택 후 > Add Artifact > Upload Artifact(s)
보통 nexus에 접근할때 settings.xml 을 설정하는데,
pom.xml에서 특정 코드를 삽입함으로서 settings.xml에 아무 설정을 하지 않아도되는 방법이 있다
pom.xml의 repositoreis에 다음과 같이 입력
<repositories>
<repository>
<id>public</id>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
pom.xml의 pluginrepositories에 다음과 같이 입력
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://localhost:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
3. mirror 설정
settings.xml에 mirror 설정을 해놓아야 nexus repository에서 lib를 다운받아 추가시킨다. 따라서 settings.xml에 다음과 같은 내용을 추가 시킨다.
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<name>Local nexus repository</name>
<url>http://localhost:8081/nexus/content/groups/public/</url>
</mirror>
</mirrors>
Reference
jar파일이 저장되는 디렉토리
D:\Program Files\nexus\sonatype-work\nexus\storage
조대협님의 기본설정 http://bcho.tistory.com/790
'APACHE > MAVEN' 카테고리의 다른 글
Maven 메이븐구조 및 설치 (0) | 2019.05.27 |
---|