개발/Web
jar 파일 의존성 한번에 다운로드 maven 사용
devbrain
2021. 1. 4. 18:12
먼저 mvn 명령이 cmd에서 실행될 수 있도록 다운로드 및 path에 등록되어 있어야 함
라이브러리를 다운로드 할 폴더를 생성
mkdir d:/jar_download
다운로드 할 jar 파일 검색 : mvnrepository.com/
테스트로 대충 jedis(redis client) 다운로드 받아보겠음
mvnrepository.com/artifact/redis.clients/jedis/3.3.0
검색을 해서 원하는 버전을 찾으면 아래와 같이 dependency 정보가 나옴
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.3.0</version>
</dependency>
생성한 d:/jar_download 디렉토리 안에 pom.xml 을 생성하여 아래 내용 붙여넣기
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>jar.download</groupId>
<artifactId>jar.down</artifactId>
<version>1.0</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.3.0</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>download-dependencies</id>
<phase>generate-resources</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory> ${project.build.directory}/dependencies </outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
pom.xml 파일이 있는 곳에서 cmd로 아래 명령 입력
mvn install
실행하면 d:/jar_download/target/dependencies 디렉토리 안에 모든 jar 파일들이 다운로드 되어있음