Maven doesn't recognize dependencies added in IntelliJ project structure - maven

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

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.

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.

Spring Boot Maven project giving error after importing on STS-4

I have the IDE Spring Tool Suite 4 and I imported the Spring Boot project generated by JHipster using the option "Import > Existing Maven project", however, the project show error in the first line which is just a comment in package-info.java and because of that the project not run when I try initialize by Boot Dashboard in IDE.
The IDE show this erros:
The project was not built since its build path is incomplete. Cannot find the class file for javax.servlet.ServletException. Fix the build path then try building this project;
The type javax.servlet.ServletException cannot be resolved. It is indirectly referenced from required .class files
I tried:
project > clean;
right click in project > Run > Maven clean;
right click in project > Maven > Update project;
Usually this steps work, but not in this project.
When i open the terminal and write mvn clean package and run the .war or execute ./mvnw the API works.
Why does this error occur in STS 4 if the terminal compiles without problems?

Other Maven project import can not be resolved

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.

Gradle: Can't resolve a variable that has to be included in external dependency

This question follows this post: Gradle: Where are external dependencies stored?.
I want to use MongoDB driver for Java, so I added the following line:
compile 'org.mongodb:mongodb-driver:3.4.0'
to build.gradle file. After finishing the build successfully, I found the jar file of the dependency in ~/.gradle/caches/modules-2/files-2.1/org.mongodb.
I also added the path ~/.gradle to external libraries.
However, when I write the statement
import com.mongodb.MongoClient;
inside my project, I get an error:
"Can't resolve symbol 'mongodb'".
Do you know how to resolve this issue?
Now IJ searches in .gradle for classfiles. Of course mongodb is not found in there. As I said in the comment of the other issue, if you change the dependencies in your Gradle file and did not enable auto-import when you imported the Gradle project into IJ, its library configuration will not automatically update. Either tell IJ manually to refresh the library configuration from the Gradle file or activate auto-import so that it automatically sees when you change the Gradle file and automatically updates the library configuration.
Make sure you opened the project as Gradle project
When you add dependency, press on the sync dependencies button

Resources