Reputation: 2257
I have created a Maven project, and have added my required dependencies. When I attempt to build the project, I get the following errors:
My dependencies do show that the org.apache.poi
library is there:
Which includes the requisite packages:
Here are my includes:
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Cell;
I'm relatively new to Java, and very new to Maven, but when I right click on
Dependencies
and Add Dependency
, I enter the appropriate groupID and ArtifactID and version, (as listed in Maven Central) and it automatically downloads the file. Not sure what else I'm missing. Any help is appreciated.
Edit: I should note that I also tried Manually installing artifact and got the same result.
Edit: Here's the dependency section of my pom.xml
file. I'm curious why maven only added two, when I have many more libs, but that seems to be another issue. POI is listed here and it's the one that the compiler is complaining about.
<dependencies>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>3.16</version>
<type>pom</type>
</dependency>
</dependencies>
Upvotes: 1
Views: 12699
Reputation: 61
Sometimes Netbeans gets confused as you are editing the pom and doesn't download from maven. Simply do a "clean and build" of your project and it will download the dependency.
Upvotes: 2
Reputation: 2257
So the solution, as odd and site-specific as it is, is still the solution. Basically here's the situation: I'm working at a company where the normal developers all use Windows for their development environments. They have specific configurations that allow them to punch through the corporate proxy so they can get to external maven repositories, configurations that not everyone else has. Because of this, tools like Eclipse (the normal IDE here) was not able to download through the proxy. Being a former Linux sysadmin, I was able to get the proxy issues resolved using NetBeans in a Linux VM. The issue, however was that all of the maven configs that I used were based in windows, and this is what I finally fixed in my settings.xml file:
<localRepository>c:\.m2\repository</localRepository>
should have been
<localRepository>.m2/repository</localRepository>
in Linux. Once I noticed that, and changed the settings (and directory name) it worked flawlessly every time. Thanks to all who responded.
Upvotes: 2
Reputation: 3834
There is no error with the configurations you have posted thus far in my environment. I have a feeling it has to do with your class path and/or Netbeans Non-classpath dependencies however I cannot be sure because I do not have the necessary visibility into your project. Did the GUI add the <type>
element to your POM.xml?
Therefore instead of trying to uncover the issue you are experiencing via question and answer I will posted a standard way to set up this project for you to compare against.
You will get the following screen.
Do you see a red line under your import?
package com.mycompany.mavenproject1;
import org.apache.poi.*;
public class Main {
public static void main(String[] args) {
}
}
Right click on your project, clean and build. Does it generate an error? If so can you post your console?
Upvotes: 2