Frage

Alright, this is driving me nuts... I am working on a Maven project and I have 3rd Party JAR dependencies that are giving me compilation errors on IntelliJ but not in STS.

My simplified project structure is like this:

FERPAPortlet
-src
--main
---java
----edu.sandiego.parent
-----FERPAPortlet
---resources
---webapp
----META-INF
----WEB-INF
-----jsp
-----lib <----- 3rd Party JARS are here
-----liferay-display.xml
-----liferay-plugin-package.xml
-----liferay-portlet.xml
-----portlet.xml
-----web.xml
--test
-pom.xml

In SpringSource Tool Suite, if I run compile/package, everything runs fine! In fact, if I run it first in STS and then reopen with IntelliJ, the issue is solved. Nonetheless, I prefer IntelliJ over STS...

A sample error I get would be something like this when I run maven compile:

[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR : 
[INFO] -------------------------------------------------------------
[ERROR] C:\Users\rico.r-10\Documents\GitHub\github.sandiego.edu\FERPAPortlet\src\main\java\edu\sandiego\parent\FERPAPortlet.java:[3,35] error: package com.sghe.luminis.core.spring does not exist

However, when I navigate to that line, IntelliJ does not highlight it red as an error and I can actually Ctrl+click and IntelliJ will navigate to the library.

I already added the libraries via Project Structure > Project Settings > Modules > MyModule > Dependencies tab.

What is STS doing that I'm missing in IntelliJ?

EDIT: Got it working! This is what I did. I deleted the lib folder with the 3rd Party Jars. I then manually added those Jar files through the command line, like so:

mvn install:install-file "-Dfile=C:\luminis5libs\luminis-dal.jar" "-DgroupId=com.sghe.luminis" "-DartifactId=luminis-dal" "-Dversion=1.6.0" "-Dpackaging=jar"

Finally, I modified the POM to include those dependencies, like so:

<dependency>
            <groupId>com.sghe.luminis</groupId>
            <artifactId>luminis-dal</artifactId>
            <version>1.6.0</version>
        </dependency>
War es hilfreich?

Lösung

You shouldn't have a lib directory. With maven, all the jars come from your local repository, and are copied into the lib directory under the target (build) directory. Check your maven dependencies, and delete lib and everything under it. Your errors are because intellij doesn't see the jars in your defined path.

Andere Tipps

Click on Maven Projects at the right border of intellij, after click on the 'Reimport all Maven projects' (the blue circular arrow)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top