0

I have created maven project in interactive mode using

    mvn archetype:generate

used Quick one. It creates default App.java I just modified the class as follows

    String greeting;
    public App(String msg)
    {
     greeting = msg;
    }

    public String getMessage()
    {   
      return greeting;
    }

And mvn compile and then mvn eclipse:eclipse and imported maven project as follows file->new->maven->existing maven project->selected sample sample contains the project.

But local has target directory with classes but eclipse has empty target directory. I just tried alt+f5

It has src folder, maven dependencies and empty target

Why target is empty here?

Any suggestions?

Gibbs
  • 21,904
  • 13
  • 74
  • 138
  • 1
    instead of using mvn eclipse:eclipse, just import the projects as Maven projects. This gives the projects the maven nature and enables alt+f5. – tdrury Jun 08 '15 at 13:53
  • Using `mvn ecllipse:eclipse` enables you to import them as regular eclipse projects, not maven projects, but it is better to import them as maven projects without thar command. – aalku Jun 08 '15 at 13:54
  • And you have to build the project to get the artifact in the target folder. Run the project build with the goal `package`. – aalku Jun 08 '15 at 13:56

3 Answers3

0

Don't use mvn eclipse:eclipse. Eclipse has had support for importing Maven projects for a while now.

Instead, once you've generated your project from an archetype, use Eclipse's "Import > Maven > Existing Maven Project" option.

Thorn G
  • 12,620
  • 2
  • 44
  • 56
0

If you want to use eclipse IDE only. The better to create new project in eclipse itself and please follow the URL.

and

To disable eclipse nature : Right click project --> Maven --> Disable maven nature

Community
  • 1
  • 1
The N..
  • 70
  • 1
  • 5
  • I don't think OP wants to get rid of Maven, he wants Eclipse to properly handle his Maven project. – Thorn G Jun 08 '15 at 14:03
  • ok. My doubt is, I have just run `maven archetype:generate` and created a sample project and imported my project in eclipse as maven project. But target folder is empty but it is not empty in local – Gibbs Jun 08 '15 at 14:04
  • Yes Tom, for the same thing I am trying to help him. – The N.. Jun 08 '15 at 14:05
  • Gops, please try to run "mvn clean install" then refresh your project in eclipse. – The N.. Jun 08 '15 at 14:07
  • Gops, I am assuming you are running this command in project home and by default it creates target directory in project home itself. If you want to specify the location to generate war, you will have to modify pom.. Something like : testWar ${CATALINA_HOME}\webapps – The N.. Jun 08 '15 at 14:18
0

Before import the project into eclipse after executing "mvn eclipse:eclipse" command also execute the below command

mvn install

If you already imported the project into eclipse then execute the mvn install command from command prompt and then refresh the project in eclipse. Hopefully your issue will be resolved.

Bacteria
  • 8,406
  • 10
  • 50
  • 67