1

I have installed maven and I created a project using this command:

mvn archetype:generate -DgroupId=com.mycompany.app -DartifactId=my-app -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

The result is there are 2 folder and 1 file created in my-app folder: src, target, and pom.xml.

Then I modify the pom.xml in order to get the all of required apache POI jars.

<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/maven-v4_0_0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany.my-app</groupId>
  <artifactId>my-app</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>my-app</name>
  <url>http://maven.apache.org</url>

  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <!-- This is what I added -->
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.10-FINAL</version>
    </dependency>
  </dependencies>
</project>

Then I run:

mvn package

but no jars downloaded into the project folder although I got message "BUILD SUCCESS".

null
  • 8,669
  • 16
  • 68
  • 98
  • 1
    You might want to depend on the `poi-ooxml` package instead, if you intend to work with most of the file formats, see the [POI Components page](http://poi.apache.org/overview.html#components) for details of what is where – Gagravarr Aug 14 '14 at 13:03

2 Answers2

4

What you've done is correct. However, the poi jars won't download to your project folder but to your local Maven repository. This is exactly what Maven is supposed to do so that you don't have to manage many libraries/jars yourself and get all in a mess. If you do a search of your local Maven repository, you should find it there.

I also suggest you read up on how Maven uses external dependencies, this is all explained here: http://maven.apache.org/guides/getting-started/index.html#How_do_I_use_external_dependencies

If you want to package up all of your dependent jars in to one big jar look here: How can I create an executable JAR with dependencies using Maven?

Community
  • 1
  • 1
Mardoz
  • 1,617
  • 1
  • 13
  • 26
  • I'm in hurry so I ended up using m2e eclipse plugin ^^, thanks anyway. – null Aug 14 '14 at 11:22
  • @suud I don't think that m2e will solve your trouble – Skizzo Aug 14 '14 at 12:54
  • 1
    @suud In a hurry to do what? If you just need the jar why not download it from the project page? Not sure why you would want it if you are using Maven though... – Mardoz Aug 14 '14 at 13:00
1

Your project has a jar packaging type. Java not support nested jar and then maven package doesn't put any jar in your project . To do this you have to use Maven Assembly Plugin or use Spring-boot to make your uber jar

Skizzo
  • 2,883
  • 8
  • 52
  • 99