Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
In Eclipse, I created a project using Maven and added pdfbox as a dependency. Eclipse automatically rebuilt the project, and I see pdfbox-2.0.11.jar in Maven Dependencies in the package explorer.
However, in my main Java file where I intend to use this:
package my.group.project;
import org.apache.pdfbox.pdmodel.PDDocument;
Eclipse tells me "The import org cannot be resolved."
What do I do?
My 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>my.group</groupId>
<artifactId>project</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>invoices</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>10</maven.compiler.source>
<maven.compiler.target>10</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>2.0.11</version>
</dependency>
</dependencies>
</project>
–
–
Just for clarification: I guess that the particular class is also visible if you extend the contents in the jar in the package browser, isn't it?
If that's the case could you maybe provide your pom.xml?
However, you could also try to clean the project via Project -> Clean
first.. Eclipse sometimes just behaves weird as you certainly know.
–
–
–
Project --> Properties --> Maven.
Uncheck the box labeled "Resolve dependencies from Workspace projects" --> Apply and Close
Right click on your project --> Maven --> Update Project...
Check the boxes "Force Update of Snapshots/Releases", "Update project configuration from pom.xml", "Clean projects"
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.