MapReduce 프로그램에서 외부 JAR 파일을 사용하고 싶은 경우 여러 가지 방법이 있습니다.
방법 | 설명 |
---|---|
라이브러리 JAR 파일을 Unpack |
|
MapReduce JAR에 라이브러리 JAR를 추가 |
|
Hadoop에 배포 |
|
라이브러리 JAR 파일을 Unpack
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>unpack</id> <phase>test</phase> <goals> <goal>unpack</goal> </goals> <configuration> <outputDirectory>${project.build.outputDirectory}</outputDirectory> <artifactItems> <artifactItem> <groupId>org.postgresql</groupId> <artifactId>postgresql</artifactId> <version>9.4.1212.jre6</version> </artifactItem> <artifactItem> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.42</version> </artifactItem> </artifactItems> </configuration> </execution> </executions> </plugin>
MapReduce JAR에 라이브러리 JAR를 추가
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> <excludeTransitive>false</excludeTransitive> <stripVersion>false</stripVersion> </configuration> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> </manifest> </archive> </configuration> </plugin>