Cannot resolve dependency class file in maven project - maven

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.

Related

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

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.

Maven takes dependency from workspace and not from local repository

I have a web maven project in eclipse, one of its dependencies is a j2se maven project that I have in the same workspace. Something curious to me is that I believed that all dependencies declared in a maven project were taken from the remote repository or a local repository but its not, I mean; even I havent done a maven install to my j2se java project(so its not located in the local repository), when I create a war from the web project this jar is included.
I think this behaviour is because of eclipse and not maven and eclipse will always takes this dependency from the workspace
2 Because of this I can change the j2se project and not have to do a maven install ever to this project,
From the point of view of maven, I should do a maven install to my j2se project in order the web project takes the dependency from the repository and not from workspace, right?
Thanks
Yes, Eclipse m2e will by default try to resolve dependencies from the workspace. In case it's not present in the workspace, it will try to resolve it from the ArtifactRepositories(your local and remote repos).
In case you want to turn off the workspace resolution, you can do that by right clicking on the Project and selecting Maven.If you uncheck that check-box, the dependencies for that particular project won't be resolved from the workspace.

maven does not copy dependencies

I have Dynamic Web Application project in eclipse that was converted to maven project.
Problem is that all dependencies are copied to:
<project>/target/<project>-SNAPSHOT/WEB-INF/lib
not <project>/WebContent/WEB-INF/lib
so when I run application from eclipse, there are no libs from maven and I get some errors.
I assume that application started from eclipse i.e on tomcat server gets it source from <project>/WebContent/WEB-INF/lib.
You should use m2e (Maven Plugin for Eclipse). It automatically adds Maven dependencies to the classpath, so you donĀ“t need them in /WEB-INF/lib while running from Eclipse.

MyEclipse 8.5 creating 'maven-archetype-quickstart' has encountered a prob?

I use the built-in maven of MyEclipse 8.5 to create maven projects.
It shows the following error:
Image is here:pic
Sorry, because I'm new I can't post pictures here yet.
I did it twice on two computers (both are MyEclipse 8.5), but the error was the same.
I use a Eclipse to do the same job and it is successful.
But when using MyEclipse 8.5 to do the job if check "create a simple project (skip archetype selection)" during the process, the project can be created and no error happens, but there is no the folder "Maven Dependencies" in the project created in Package Explorer.
Is this a bug of this version of MyEclipse? Because Eclipse Indigo works fine on this.
If you create a simple project, the folder Maven Dependencies is missing simply because there are no Maven Dependencies in a simple project. Just add a dependency, and the folder Maven Dependencies should be created with your dependency in it.

Resources