Installing Maven and creating a maven project in eclipse - java

I am new to using maven project and i am trying to create a maven project and i followed the instructions to create one in eclipse and i gave the groupId and artifact id to it and clicked Finish, for which it gave me an error stating
"No marketplace entries found to handle
maven-compiler-plugin:3.1:compile in Eclipse. Please see Help for
more information."
For this issue i tried googling and stack overflow and i saw people asking other people to change the installation directory of maven inside
Window-> Preferences -> Maven-> Installation
I tried that and tried to update the maven project but still i have some errors, i am not able to setup my project, Could someone please help?
I am attaching the errors herewith.

First you can try to install maven globaly. follow the steps.
Download maven from maven download link
Create or export M2_HOME="MAVEN ROOT LOCATION". Ex. : E:\SoftwareRepo\building tools\apache-maven-3.5.2
Create or export MAVEN bin folder location to PATH variable.
For example: E:\SoftwareRepo\building tools\apache-maven-3.5.2\bin
Open terminal or cmd and run mvn --version to confirm maven is installed or not.
Then go to eclipse. and setup project.follow this steps
Import existing maven project or create a maven project
Goto project explorer and Right click on your pom.xml
then select Run As maven install.
and then what you want.
Hope it will serve your purpose. You can download a sample spring boot project from sample spring boot project
Or you can run a maven project from terminal or cmd. Just goto project root folder and then run a maven task like maven clean install .
Happy Coding :)

If a Maven project is configured to use ecj compiler, the following errors appear when importing the project into eclipse:
No marketplace entries found to handle maven-compiler-plugin:2.3.2:compile in Eclipse. Please see Help for more information.
No marketplace entries found to handle maven-compiler-plugin:2.3.2:testCompile in Eclipse. Please see Help for more information.
A fix should be trivial.
http://git.eclipse.org/c/m2e/m2e-core.git/tree/org.eclipse.m2e.jdt/lifecycle-mapping-metadata.xml reads:
<parameters>
<compilerId>javac</compilerId>
</parameters>
It should read:
<parameters>
<compilerId>javac</compilerId>
<compilerId>eclipse</compilerId>
</parameters>
Reproducible: Always
Steps to Reproduce:
1. Unpack example zip provided
2. Try to import it to Eclipse: File->Import->Maven->Existing Maven Projects

First install Java and then create the maven project.
Install the stable Java version in the system.
If Java is not installed then these types of errors will be displayed.
No marketplace entries found to handle
maven-compiler-plugin:3.1:compile in Eclipse.
Take a look at Help for more information.

Related

how to run maven project from github in eclipse

I use eclipse and I want to compile and run this code from gitub https://github.com/openphacts/Validator ,it needs maven project to build it but unfortunately I don't know how to proceed with it. Can someone help me how to get this project into eclipse to run it and test it in my machine please? It's emergency
Once you've checked out the project from github, you need to utilize maven to install the dependencies and build the project. In the root folder of the project (where the pom.xml is located), enter the following in your command line:
mvn install
More details can be found here: https://maven.apache.org/run-maven/
Additionally, you must first download the maven command line tool: https://maven.apache.org/download.cgi
And install it: https://maven.apache.org/install.html

Unable to create project from archetype in Eclipse Luna

I am trying to create a simple Maven project in Eclipse Luna. As this is my first maven project so I am starting with a simple one. I am trying to crate a simple web project using the webapp-j2ee14 archetype.
While creating I found that this archetype is not present in archetype list. So I tried with Add Archetype option and Provided the following archetype options.
<archetype>
<groupId>org.codehaus.mojo.archetypes</groupId>
<artifactId>webapp-j2ee14</artifactId>
<version>1.3</version>
<repository>http://repo1.maven.org/maven2/org/codehaus/mojo/archetypes/webapp-j2ee14/1.3/</repository>
</archetype>
The above code snippet is basically from archetype-catalog.xml file in .m2 directory in my system, but I actually entered them from eclipse UI.
Now, when I am clicking finish it's giving me the following error...
I tried with few other repo url after searching google but getting the same error. Where can I get the correct repo url for this archetype??
Thanks in advance...
Add Remote Archetype in your eclipse it will show you that option. Following are the steps:
File--->New---> Maven Project---->Next--->Click on tab Configure
Separate window will open... Maven-->Archetypes-->Click on Add Remote Catalog--> In Catalog File type "http://repo1.maven.org/maven2/archetype-catalog.xml" and click on Apply and then Ok
Now in new Maven Project select Remote Archetype from Catalog and you will find webapp-j2ee14 option there.
I got the same problem and i was creating a simple Web App. I created the MAVEN project first then i deleted it and again when i created it i got this error. So i changed the version of archetype. I was using 2.16 version of the archetype that i was adding to my MAVEN project, changed it to latest 2.26 and it worked for me.
You can check the latest version from http://repo1.maven.org/maven2/archetype-catalog.xml
I got this problem as I have deleted a previously created project from Eclipse.
Later, I deleted the .metadata file and the project from workspace. Then this problem was resolved.
I got same issue, I have solved by manually removing unused pom.xml file at the working workspace or root of workspace directory.
I think the work space has messed up of some reason. These steps below may help
Close eclipse
delete the .metadata directory
Restart the eclipse, pointing to same workspace and try the process to create new maven project
or if this approach didn't work
switch to a fresh new workspace and try the same process to create your maven project
This is worked for me!
After working whole day, finally I found the solution. I just went to Eclipse marketlace(help-Eclipse marketplace) and updated maven from there. Now it works wonders. Earlier I was unable to install TestNG plugin from Eclipse marketplace, but now after updating maven from there, Testng plugin successfully installed in my eclipse luna.
I was trying to create a maven archetype quickstart and faced this issue, I have never created any maven project before so for those below is the steps you need to follow -
Go to to Run -> Run As -> Maven Install
In the project explorer right click on pom.xml file -> Maven -> Update project.
This will for sure resolve the issue.
Eclipse version I am using : 2021-09 (4.21.0)

Cannot run project from SVN repository

I've never worked with SVN-repositories before.
My co-worker gave me access to his repository, I downloaded the SVN plugin for eclipse, established a connection and checked out the java project. It's now locally available, but unfortunately it's not possible to run it.
I have the feeling, that Eclipse doesn't recognize this project. My other Java project are of course executable.
These are the project properties of my random test Java project:
And these are the project properties of the checked out project. As you can see, some attributes (e.g. Java) are missing:
Also the project name has a strange additional character:
"> software"
When I try to add a run configuration, I only can choose my random test project:
PS: The SVN project works with Maven dependencies. I've installed Apache Maven 3.2.1 and the m2e plugin and linked the directory with Eclipse:
Could Maven be the problem?
Thank you!
Try to check the .project file and the .classpath file...
Those file tells to Eclipse the kind and the structure of the project...
So if they are missing this could cause a lot of problems...
Those file will be also generated if you do something like Configure > Convert to Java (like azurefrog tells in comments)
Right click on your project> team> disconnect. Hope so this will help.

How to build and run Maven projects after importing into Eclipse IDE

I am learning building a Java project in Eclipse using Maven. I created a Java project HelloWorld from
“maven-archetype-quickstart” template in a folder D:/maven_projects. Then to convert the Maven project to support Eclipse IDE, I navigated into the project folder and issued the commands:
mvn eclipse:eclipse and mvn package .
Then I imported the project in Eclipse and did the necessary Eclipse configurations like setting the Maven local repository in Eclipse classpath. Now the project in D:/EclipseWorkspace folder. I ran the project successfully in Eclipse printing "helloworld".
Now if I want to go on develop the project and for that reason want to add new dependencies in pom.xml in Eclipse, then the new jars are not added in classpath when I run the project.
So my question is after importing a Maven project into Eclipse how can I add more and more dependencies in pom.xml, then build and run the project? What is the recommended and efficient way to do this?
I would recommend you don't use the m2eclipse command line tools (i.e. mvn eclipse:eclipse) and instead use the built-in Maven support, known as m2e.
Delete your project from Eclipse, then run mvn eclipse:clean on your project to remove the m2eclipse project data. Finally, with a modern version of Eclipse, just do "Import > Maven > Existing project into workspace..." and select your pom.xml.
M2e will automatically manage your dependencies and download them as required. It also supports Maven builds through a new "Run as Maven build..." interface. It's rather nifty.
1.Update project
Right Click on your project maven > update project
2.Build project
Right Click on your project again. run as > Maven build
If you have not created a “Run configuration” yet, it will open a new configuration with some auto filled values.
You can change the name. "Base directory" will be a auto filled value for you. Keep it as it is. Give maven command to ”Goals” fields.
i.e, “clean install” for building purpose
Click apply
Click run.
3.Run project on tomcat
Right Click on your project again. run as > Run-Configuration.
It will open Run-Configuration window for you.
Right Click on “Maven Build” from the right side column and Select “New”.
It will open a blank configuration for you.
Change the name as you want. For the base directory field you can choose values using 3 buttons(workspace,FileSystem,Variables). You can also copy and paste the auto generated value from previously created Run-configuration. Give the Goals as “tomcat:run”. Click apply. Click run.
If you want to get more clear idea with snapshots use the following link.
Build and Run Maven project in Eclipse
(I hope this answer will help someone come after the topic of the question)
Dependencies can be updated by using "Maven --> Update Project.." in Eclipse using m2e plugin, after pom.xml file modification.
Just install the m2e plugin for Eclipse. Then a new command in Eclipse's Import statement will be added called "Import existing maven projects".
answer 1
Right click on your project in eclipse
go to maven -> Update Project
answer 2
simply press Alt+F5
after updating your pom.xml. This will build your project again and download all jar files
Right Click on your project
Go to Maven>Update Project
Check the Force Update of Snapshots/Releases Checkbox
Click Ok
That's all. You can see progression of build in left below corner.
When you add dependency in pom.xml , do a maven clean , and then maven build , it will add the jars into you project.
You can search dependency artifacts at http://mvnrepository.com/
And if it doesn't add jars it should give you errors which will mean that it is not able to fetch the jar, that could be due to broken repository or connection problems.
Well sometimes if it is one or two jars, better download them and add to build path , but with a lot of dependencies use maven.
If you are getting this error :in cucumber Exception
Cucumber Exception: java.lang.ClassNotFoundException:
cucumber.io.ResourceLoader :
then add following jar file to your pom.xml
<dependency>
<groupId>info.cukes</groupId>
<artifactId>cucumber-core</artifactId>
<version>1.1.8</version>
</dependency>
Run the maven build once and should be gone

Errors after importing Maven project into Eclipse

I imported a Maven project into Eclipse. I was able to deploy it from the command line. In Eclipse it is full of red Xs. I have cleaned the project, updated the configuration and I ran the following command:
mvn -Declipse.workspace=<pathtoworksapce> eclipse:add-maven-repo
and I still have the same problem. The project is dependent on another project.
What I ended up doing was removing all of the projects in Eclipse, but not deleting the source files. Then instead of directly importing the code as Maven->Check out as Maven Projects with SCM, I selected Existing Maven Project and imported the code from my local machine. This got rid of the errors, but when I would right click on code and select "Open Declaration", I would get Error: Could not open the editor: The file does not exist" So I removed all projects again and this time I deleted all the ".project" files and repeated the import Existing Maven Project. So now there are no red Xs (dependency problems) and the lookup functionality within the code works.
Go to your master project and type the following :
mvn install
mvn eclipse:eclipse
After that, import your project. You can also install m2eclipse for better support. If you use gwt or any other framework which has a custom maven execution, you should also install plugins for those in Eclipse.

Categories