Other Maven project import can not be resolved - maven

In my Eclipse maven Project pom.xml, there are two other maven project dependencies(project1 and project2). I was able to use all those classes in my Project. I did git pull which had pom.xml changes('htmlunit' dependency was added). Then my project started showing error 'import can not be resolved' for the classes defined in project1 only and project2 imports are fine. And I am able to build, deploy the project successfully in terminal but getting those errors in my eclipse IDE only.
Can someone help me how to solve this error "other maven project classes import cannot be resolved"?
Is there anything to be taken care when pom.xml is modified?I tried project->clean, maven->update project.

Related

Maven Build Scripts Found - IntelliJ - What are the build scripts, where are they cached?

So basically, as the title of the post states, I'm wondering what IntelliJ is referring to when it says that Maven build scripts were found? Are these scripts that Maven keeps cached or are they IntelliJ specific? If they are generated by Maven, where are they stored/ how can I view them if that is possible?
Thanks!
This notification is to inform you that you are working with IntelliJ IDEA project that is not linked to the external build system (Maven or Gradle).
When you open a project in IntelliJ IDEA that was not initially imported from Maven/Gradle and IDE detects pom.xml or build.gradle files in the project, it will display a notification so that you can properly import the project from the build script.
Build script in your specific case is a pom.xml file stored inside a project directory. It's recommended that you open Maven projects by importing the root pom.xml file.
When a project is not imported from the external build system, your source roots configuration may be incomplete and you may be missing the dependencies.

Maven doesn't recognize dependencies added in IntelliJ project structure

I need to use external dependencies for tomcat. I add them to project structures and project build fine. Compiler doesn't show any errors
project structure
The project works fine when i run it on IDE.
The problem starts when I try to build WAR file using Maven package :
package org.apache.catalina does not exist
package org.apache.catalina.connector does not exist
package org.apache.coyote does not exist
I've try with all different scope settings but jars aren't found

Cannot resolve dependency class file in maven project

I am facing issue in importing class files from dependency project though the dependency jar is downloaded in the Maven dependencies path in STS IDE.
I have created 2 maven spring-boot projects where one is app and other is database. I have installed database maven project in local maven repositories using maven install commands.
When I use the database project as dependency in app project, maven is downloading the dependency of database project jar and placing it in Maven dependencies path. But I could not import the class files from database project jar. It says "class name cannot be resolved" error.
I have tried importing the database project in STS IDE. The app project could able to load classes only if database project is opened in the workspace. If I close the database project, then I am getting error in importing class files in app project.
I am using below "spring-boot-maven-plugin" plugin to build database jar.
I would expect to import the database project classes in the app project but I am getting import errors.
Kindly advice me on fixing this issue.

Error package does not exist in Intellij but working in Spring Tool Suite STS

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>
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.
Click on Maven Projects at the right border of intellij, after click on the 'Reimport all Maven projects' (the blue circular arrow)

How to force intelliJ to import a maven dependency with classifier as a "Maven Library" instead of "Intellij Module"

In my maven based IntelliJ project I have 2 modules - modules A and B.
The pom.xml of module A creates an uber jar (including dependencies which are not accessible by the project) and attaches it as an artifact with classifier "withdeps"
The pom.xml of module B has a dependency on the classified "withdeps" artifact A
When I import the maven modules IntelliJ adds the module's A source code in the dependencies of module B (ignoring the "withdeps" classifier).
Is it possible to force Intellij to add the module A dependency to B as "maven library" instead of the default "project source code/Intellij module"? If not what can I do to resolve the compilation errors in IntelliJ (Ctrl+F9)
Thanks
Open the pom.xml of module B only when creating the intellij project. Then all dependencies will be as maven dependencies.
The downside is that this way you will have to open module A as separate project in another window, then when you change something you will have to do mvn install and refresh project B.
Much better solution would be to install all depencencies into maven repository, described here in maven docs.

Resources