Contents
see List작성일 2017. 10. 12.
Maven에 외부 JAR 추가하기
Maven 중앙 저장소에 없는 JAR 파일을 프로젝트에 추가하는 방법입니다. 상용 라이브러리나 사내 라이브러리를 사용할 때 필요합니다.
언제 사용하나요?
- 오라클 JDBC 드라이버 등 라이선스 문제로 중앙 저장소에 없는 JAR
- 사내에서 개발한 공통 라이브러리
- 서드파티 벤더가 제공한 SDK
- 오래된 버전의 라이브러리
방법 1: 로컬 저장소에 설치 (권장)
# JAR을 로컬 Maven 저장소에 설치
mvn install:install-file
-Dfile=ojdbc8.jar
-DgroupId=com.oracle.database.jdbc
-DartifactId=ojdbc8
-Dversion=21.1.0.0
-Dpackaging=jar
# pom.xml에 의존성 추가
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>21.1.0.0</version>
</dependency>
방법 2: 시스템 스코프 (비권장)
<!-- 프로젝트 내 lib 폴더에 JAR 위치 -->
<dependency>
<groupId>com.example</groupId>
<artifactId>custom-lib</artifactId>
<version>1.0</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/custom-lib.jar</systemPath>
</dependency>
<!-- 주의: 빌드 시 WAR에 포함 안됨 -->
<!-- 추가 설정 필요 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webResources>
<resource>
<directory>${project.basedir}/lib</directory>
<targetPath>WEB-INF/lib</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
방법 3: 프로젝트 내 로컬 저장소
<!-- 프로젝트 내 저장소 정의 -->
<repositories>
<repository>
<id>local-repo</id>
<url>file://${project.basedir}/lib</url>
</repository>
</repositories>
<!-- lib 폴더 구조:
lib/
└── com/
└── example/
└── custom-lib/
└── 1.0/
├── custom-lib-1.0.jar
└── custom-lib-1.0.pom
-->
<dependency>
<groupId>com.example</groupId>
<artifactId>custom-lib</artifactId>
<version>1.0</version>
</dependency>
방법 4: Nexus/Artifactory 사내 저장소
<!-- settings.xml에 저장소 추가 -->
<servers>
<server>
<id>company-repo</id>
<username>deploy</username>
<password>password</password>
</server>
</servers>
<!-- pom.xml에 저장소 정의 -->
<repositories>
<repository>
<id>company-repo</id>
<url>https://nexus.company.com/repository/maven-releases/</url>
</repository>
</repositories>
<!-- JAR 배포 -->
mvn deploy:deploy-file
-Dfile=custom-lib.jar
-DrepositoryId=company-repo
-Durl=https://nexus.company.com/repository/maven-releases/
-DgroupId=com.company
-DartifactId=custom-lib
-Dversion=1.0
오라클 드라이버 특별 케이스
<!-- Oracle 19c 이후 Maven Central에서 제공 -->
<dependency>
<groupId>com.oracle.database.jdbc</groupId>
<artifactId>ojdbc8</artifactId>
<version>21.1.0.0</version>
</dependency>
<!-- 오래된 버전은 수동 설치 필요 -->
mvn install:install-file
-Dfile=ojdbc6.jar
-DgroupId=com.oracle
-DartifactId=ojdbc6
-Dversion=11.2.0.4
-Dpackaging=jar
소스/Javadoc과 함께 설치
mvn install:install-file
-Dfile=library.jar
-Dsources=library-sources.jar
-Djavadoc=library-javadoc.jar
-DgroupId=com.example
-DartifactId=library
-Dversion=1.0
-Dpackaging=jar
설치 확인
# 로컬 저장소 확인
ls ~/.m2/repository/com/example/custom-lib/1.0/
# 의존성 트리 확인
mvn dependency:tree
권장 순서
- Maven Central에서 검색
- 사내 Nexus/Artifactory 사용
- 로컬 저장소 설치
- system scope (최후 수단)
database
| No | 작성일 | Title |
|---|---|---|
| 3380 | 2026. 08. 20. | PostgreSQL 느린 조회를 진단하는 방법: EXPLAIN ANALYZE와 복합 인덱스 실전 가이드 |
| 3348 | 2026. 08. 11. | PostgreSQL 잠금 대기 줄이기: 트랜잭션 범위와 lock_timeout 설정 실전 가이드 |
| 3316 | 2026. 08. 03. | PostgreSQL 백업 복구 실전 가이드: pg_dump·pg_restore로 장애 복구 절차 만들기 |
| 3284 | 2026. 07. 26. | PostgreSQL 인덱스가 있는데도 느린 쿼리 해결하기: EXPLAIN ANALYZE와 복합 인덱스 설계 |
| 3254 | 2026. 07. 18. | PostgreSQL 잠금 대기 진단 가이드: pg_stat_activity로 블로킹 쿼리 찾고 장애 줄이기 |
| 3202 | 2026. 07. 09. | PostgreSQL 백업 복구 검증 가이드: pg_dump와 psql로 실제 복원까지 확인하기 |
| 3170 | 2026. 07. 01. | MySQL 느린 쿼리 원인 찾기: EXPLAIN과 복합 인덱스 점검 가이드 |
| 3116 | 2026. 06. 23. | PostgreSQL 트랜잭션 충돌 줄이기: 잠금 순서와 짧은 재시도로 데드락 대응하기 |
| 3058 | 2026. 06. 15. | PostgreSQL JSONB 조회 튜닝: GIN 인덱스와 생성 컬럼으로 느린 검색 줄이기 |
| 2971 | 2026. 06. 07. | MySQL/MariaDB 복합 인덱스 설계: 느린 목록 조회를 줄이는 WHERE·ORDER BY 점검법 |