Issue
I don't understand exactly what is the way of working with maven projects in Eclipse. The problems I have are often with projects I download from github. If I set the project myself it usually work, so I think I'm doing something different from the majority of people.
I'll try to detail a specific case:
- I clone a repo, let's say: https://github.com/spring-guides/tut-spring-boot-oauth2
- In Eclipse I import "existing maven project"
- The project has a "Maven nature" as indicated by M on the folder icon
- I try to run java class with main from Eclipse. First strange thins is that the "Run As" menu doesn't have "Run as a Java application"
- I have to configure the configuration manually. Now it runs, but strange things happens, like I can't edit the file as the "content assist" throw errors instead of giving the normal assists.
- I notice that the project has no "source folder". So my first instinct is to add a Java nature or select src as source folder
- So I add Java nature to the project. This is a disaster. It can compile anymore as it can find packages. All classes have errors. I try to play around setting source folders on /src or /src/main/java. Sometimes I fix the errors but I can't run (and now I have run as Java application) but when I run it can't load the class
So in the end, I'm a bit confused and I don't know if I explained clearly what I'm doing. I think I would like to know in a simple way how people are doing it, rather than trying to correct my steps as I'm probably creating a mess myself.
Any help or suggestion welcome. I'm using the last version of eclipse. I don't know which other tool's versions are relevant.
P.S. I also refresh,restart,clean rebuild the project often after touching things...but it doesn't get better
Solution
Maven is a build (management) tool. Simply spoken, its task is to create a JAR that can be used as a dependency/library by other projects or when running java -jar ...
.
Running a project's code isn't part of it (apart from unit and integration tests code and by using non-default plugins for special situations). Running code is part of Eclipse (or any other IDE) with its Run Configurations.
Answered By - Gerold Broser