0

In my project I need to reference to the package installed by Maven to local repository. I've added the dependency to pom.xml, but the project doesn't want to build as it wouldn't even see the package. Here's the pom.xml fragment with dependencies:

<dependencies>
  ...
  <dependency>
    <groupId>libraryweb</groupId>
    <artifactId>classes</artifactId>
    <version>1.0SNAPSHOT</version>
  </dependency>
</dependencies>

When I try to import the package "libraryweb" I get

Cannot resolve symbol 'libraryweb'

error. What can I do to use the package?

Edit: Intellij prompts me classes from the package when I try to use them, but I still get "cannot resolve symbol" error.

Hellmick
  • 99
  • 2
  • 11
  • 1
    does this answer your question https://stackoverflow.com/questions/4955635/how-to-add-local-jar-files-to-a-maven-project?rq=1 – J Asgarov Feb 08 '22 at 10:32
  • @JAsgarov no, I've already installed the package using mvn install:install-file as in the post, the problem is I can't reference to the package in Java code. – Hellmick Feb 08 '22 at 10:34
  • @Hellmick As Asgarov mentioned in his link , you need to add the system path in maven to point your local jar in pom.xml for using in your project – Umeshwaran Feb 08 '22 at 10:35
  • @Umeshwaran even if it's installed in Maven repo? I provided the systempath to the jar in repo, but now I get "'dependencies.dependency.systemPath' for libraryweb:classes:jar must be omitted. This field may only be specified for a dependency with system scope." error. – Hellmick Feb 08 '22 at 10:43
  • Maybe typo? `1.0SNAPSHOT` -> `1.0-SNAPSHOT`. – Max Daroshchanka Feb 08 '22 at 11:06
  • @MaxDaroshchanka nope, it was generated by mvn:install like that – Hellmick Feb 08 '22 at 11:13

2 Answers2

0

Note that groupIds and package names are not necessarily the same.

So while your JAR is installed under a certain groupId, artifactId and version, the actual package that you need to import in your Java code may have a different name.

In doubt, unpack the JAR and look at the directory structure.

J Fabian Meier
  • 33,516
  • 10
  • 64
  • 142
  • I unpacked the JAR, there are just .class files. I've tried to import that using really different name configurations and still get the same error. – Hellmick Feb 08 '22 at 11:04
-1

I solved the problem by linking the .jar file with IntelliJ projects settings instead of using Maven to do it.

Hellmick
  • 99
  • 2
  • 11