Intellij does not see maven dependencies.

Answered

Hi!

 

I have maven project. I added this dependecy to pom.xml:

    <dependency>
      <groupId>org.locationtech.jts</groupId>
      <artifactId>jts-modules</artifactId>
      <version>1.18.2</version>
      <type>pom</type>
    </dependency>

 

But when I try to use

import org.locationtech.jts.geom.Geometry;

in my code then locationtech is red in idea.

 

When I download dependencies from command line then everything works:

C:\project>mvn dependency:copy-dependencies | grep location
[INFO] org.locationtech.jts:jts-modules:pom:1.18.2 already exists in destination.



Why can't Idea see this?

0
2 comments

You have a pom type dependency, that's not what you need when you want to reference a Java library. You need a jar. Check the artifact being imported: it's not what you expect.

>in my code then locationtech is red in idea.

This means that this class is not in fact in the classpath of the application. You can confirm this by compiling this project by Maven itself from the command line: mvn clean compile. So here the IDE behaviour is correct.

In fact, on a Maven repository I see this dependency of type pom does not provide any compile time dependencies. Only Test dependencies (1) and Managed dependencies (5).

As I see this class is available in the following dependency:

<dependency>
<groupId>org.locationtech.jts</groupId>
<artifactId>jts-core</artifactId>
<version>1.17.1</version>
</dependency>
0

Tnx.

 

I learned that I needed

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-spatial</artifactId>
    <version>${hibernate.version}</version>
</dependency>

instead.  Now I have it without manually adding jar file.

I didn't have too much experience with maven myself as I don't add new dependencies every day, now I learnd what I should look for. Thanks.

0

Please sign in to leave a comment.