I have a maven project in Eclipse which has as a dependency another project which I've installed in my local repo with mvn clean install. The dependency in pom:
<dependency>
<groupId>com.mycompany</groupId>
<artifactId>mydependency</artifactId>
<version>1.0.0</version>
</dependency>
When I run the project from eclipse in tomcat, Run On Server, it runs fine If I don't have the other project loaded in eclipse(mydependency). If I import mydependency as a maven project in eclipse(I need to for debugging purposes), the project fails on runtime with ClassNotFoundException. It cannot find classes of mydependency project.
What am I doing wrong?
P.S. I've tried the usual, clean, delete, reimport projects, switch workspaces, delete/recreate tomcat in eclipse, even switched eclipse installation...
First solution:
Choose on your project right-click-> Maven -> Disable workspace resolution
Now when you will debug the debugger will find the jar file - not the source. You has to attach source code to the library (choose java project)
Second solution
Run your project on tomcat as war file and debug remotely.
Third solution
Install JD-Eclipse . It is helpful, but sometimes the lines of code are not the same as decompiled.
Related
That is pretty easy in Ultimate Itellij Idea.
In community version I have the following problems:
I can't open maven lifecycle window.
When I right click on pom.xml and choose Maven I see only
Using artifacts + build it's impossible to choose .war
It's worth saying that I have mvn project and I need to create .war from one of the subprojects
Are you sure you can't enable the Maven Tool window?
I'm using the Community Edition (2018.3, so not the latest one) and the Maven tool window is available (appears by default on the right), see below:
If you can't find it, try View/Tool Windows/Maven
You can achieve doing cmd into your project root folder and run the maven goal mvn clean install or mvn clean package
Before that make sure you define your project with as packaging of war type and also check you have maven installed and set maven home
<groupId>...</groupId>
<artifactId>...</artifactId>
<version>...</version>
<packaging>war</packaging>
I'm using Eclipse Luna for my project. I've imported a Maven project into it. Right click->import->import existing maven projects. I made mvn clean package install under run configurations. It ran successfully till mid of project, and in the sub modules, it got failed due to some issue in Java file. But whatever the JAR's that have been fetched should be displayed under Maven dependencies under Build path right?
Here is the screenshot
Do I require to make any steps here?
Right click the project and Configure as Maven project
I'm working in eclipse on a java / javascript project, we're using maven to manage our project dependencies, I ran into a issue with maven build (clean install) does not install the dependencies that I specified in the POM.xml file, I tried everything I can find on the internet the whole day today, still no luck, I'll be really appreciate if anyone could kindly take a look at, thank you :)
I got a reuse lib project (lib) and a working project (project), the project should be installing the lib during the maven build, So, here's more detail information on what exactly I did:
I ran maven clean on the lib, then ran maven package, the lib-1.0.0-SNAPSHOT.jar file was generated successfully.
then in the working project POM.xml file, I added the dependency declaration.
I right clicked the working project, maven -> update maven project, where I checked the 'force update of snapshots / releases' checkbox, then -> ok
I right clicked the working project, run as -> maven build (with clean install, and also I checked on the 'Update Snapshots' checkbox) -> apply -> run
In the console, I saw the reuse lib was downloading and then downloaded, but it's never got installed (there should be a line says installing reuse lib...), as the result of it, the reuse lib will not be loaded after I ran my working project, it drives me insane -_-!..
Only your maven projects build output can be installed (in the local repository with mvn install, resp. mvn clean install). During the build it will resolve the dependencies (and the transitive dependencies) to be downloaded and packed to your delivery. Those dependencies of your project will implicitly also be "installed" in your local repository since you will see them in your local repository after the download happened - Maven will however not see that as a install in the meaning of install of the default lifecycle.
To install your "reuse lib"-Maven project you will have to run mvn install or mvn clean install on that project's pom rather than on a project which "just uses it as dependency".
Having projects A and B in Eclipse, where A has a dependency on B, everything works fine if I try to "Run As/Java Apparication" A from Eclipse. However, when I try to "Run As/Maven Build...", it complains:
The POM for groupname:projectb:jar:0.0.1-SNAPSHOT is missing, no dependency information available
and then later it attempts to download my local dependency from Nexus and that of course fails.
"Resolve workspace artifacts" is enabled in the Maven run configuration. "Workspace resolution" is enabled for all projects. I have already tried:
disabling/enabling everything
Project/Clean everything
Maven/Update Project everything
Installed an external Maven (3.2.1) and repeated all of the above
Using latest Eclipse Kepler with everything updated.
Ideas ?
when you run app it resolves artifact from workspace and it doesn't look into maven local repository, when you invoke maven command from eclipse (maven build) it invokes native mvn or embedded in both case it looks up for dependency in local maven repository and it doesn't find it
so to fix this, you run maven build on project B first with goal mvn clean install and then invoke your maven build on project A that will work
I have a maven project which won't compile due to an unresolvable reference from another project's artifact.
When I run eclipse:eclipse and open it up it shows an auto fix suggestion of "Add project 'project2' to build path of 'project1'". If I click this everything works. So project1 can clearly see my project2 reference, but doesn't quite use it as expected.
However, once I delete all the files generated for eclipse the error resumes because whatever reference eclipse created has been removed. How can I get this project2 in the project1 build path manually. I already have it listed in the pom as below:
<dependency>
<groupId>group.id</groupId>
<artifactId>project2</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
In "Project properties > Maven" menu you should check "Resolve dependencies from Workspace projects".
When I run eclipse:eclipse[...]
This sounds like you are using the Maven Eclipse plugin. You should probably rather use m2e, which is the recommended way to integrate with Maven now. This will also obviate the need to run mvn eclipse:eclipse. Instead, just import your Maven project into Eclipse, and it will pick up everything automatically.
After you set "Resolve dependencies from Workspace projects" as described in polypiel's answer, things should just work (TM).
If you have maven nature to both your projects, you should do mvn clean install to both the projects, so they will be installed in your local repository and will be available for other projects to use as dependencies. Or just right click to both the projects in eclipse and choose Run As --> Maven install