0

I am very new to maven was about to start learning spring with maven but when I created my first project with maven in eclipse this error occurred and I think maven plugins are not getting downloaded. I have tried several solutions from stackoverflow but nothing worked.

Console Window is like :-

[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.097 s
[INFO] Finished at: 2020-06-01T21:17:39-07:00
[INFO] ------------------------------------------------------------------------
[ERROR] No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format <plugin-prefix>:<goal> or <plugin-group-id>:<plugin-artifact-id>[:<plugin-version>]:<goal>. Available lifecycle phases are: validate, initialize, generate-sources, process-sources, generate-resources, process-resources, compile, process-classes, generate-test-sources, process-test-sources, generate-test-resources, process-test-resources, test-compile, process-test-classes, test, prepare-package, package, pre-integration-test, integration-test, post-integration-test, verify, install, deploy, pre-clean, clean, post-clean, pre-site, site, post-site, site-deploy. -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException

Error window is like this:-

Please see this screenshot for exact information of errors.

Screenshot attached

POM.xml file

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.anuragr07</groupId>
  <artifactId>springpractice</artifactId>
  <version>0.0.1-SNAPSHOT</version>
</project>

Solutions tried so far:-

  1. Installing maven using help > install a new software option
  2. Tried mvn install using cmd
  3. Tried uncommenting proxy tag in setting.xml file
  4. Tried 'https' instead of 'http' in proxy tag in settings.xml file
  5. Tried reinstalling eclipse

and maybe more..

After mvn package

E:\Workspace\springpractice>mvn package
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------< com.anuragr07:springpractice >--------------------
[INFO] Building springpractice 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
Downloading from central: https://repo.maven.apache.org/maven2/org/apache/maven/plugins/maven-resources-plugin/2.6/maven-resources-plugin-2.6.pom

**Downloaded all the plugins**

[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  20.831 s
[INFO] Finished at: 2020-06-01T23:52:35-07:00
[INFO] ------------------------------------------------------------------------

I am really frustrated and searching for solutions from past 24 hours. Please help me resolve this.

Thanks!

Anurag Rawal
  • 15
  • 1
  • 7
  • Could you share your `pom.xml`, there might be something wrong with your pom file as the error message reads that no goal is specified for the build. @Anurag Rawal – Ananthapadmanabhan Jun 02 '20 at 04:53
  • Yes sure, I have shared it. Can you please check it. @Ananthapadmanabhan – Anurag Rawal Jun 02 '20 at 05:23
  • The build is failing because you haven't provided any `build` goal in your pom file. – Ananthapadmanabhan Jun 02 '20 at 05:34
  • 1
    Try the following. 1. Close the eclipse first - try to work in CMD and configure maven there. Remove setting.xml in your user directory if the file exists there. 2. Download Maven from official site. 3. Add the path to %MVN_HOME%\bin to the Path env. variable in windows. 4. open CMD and cd to the folder where you have a pom.xml. 5. Type: mvn package. 6. Post the output. – Mark Bramnik Jun 02 '20 at 05:36
  • Does this answer your question? [specifying goal in pom.xml](https://stackoverflow.com/questions/19852950/specifying-goal-in-pom-xml) – leopal Jun 02 '20 at 06:36
  • Did that but real issue is plugins. @leopal – Anurag Rawal Jun 02 '20 at 06:47
  • I think it worked @MarkBramnik – Anurag Rawal Jun 02 '20 at 06:53
  • First try to build your project from plain command line ..via `mvn clean package`... – khmarbaise Jun 02 '20 at 06:56
  • Thanks @MarkBramnik it did work. It did not worked on the project I have created earlier but when I tried creating new project and it was all okay with no errors. I think there was some issue with the settings.xml file. Can you refer me some links or resources to grab some maven and spring concepts. – Anurag Rawal Jun 02 '20 at 07:08
  • Now I am getting another error, which is 'cound not resolve archetype' when I create a new project using an archetype. But it is working with normal project in which I skip archetype. Can you suggest something? @MarkBramnik – Anurag Rawal Jun 02 '20 at 09:52

3 Answers3

0

you have to designate maven goal. in pom.xml, insert that

<build>
    <defaultGoal>install</defaultGoal>

</build>

I guess there is no defaultGoal in your pom.xml.

Akin Okegbile
  • 1,108
  • 19
  • 36
hyojin
  • 1
  • 1
0

The given ERORR is the cause of the default goal.

ERROR No goals have been specified for this build. You must specify a valid lifecycle phase or a goal in the format : or :[:]:.

Resolution:

Specify any goal in your run configuration for maven build like clear, compile, install, package.

install ...

Could you please refer to the given steps?

  • Right click on your project.
  • Click 'Run as' and select 'Maven Build'
  • Edit Configuration window will open.
  • write any goal but your problem specific write 'package' in Goal text box.
  • Click on 'Run'
0

There was an issue with the settings.xml file and the solution is:-

  1. Close the eclipse first - try to work in CMD and configure maven there. Remove setting.xml in your user directory if the file exists there.

  2. Download Maven from official site.

  3. Add the path to %MVN_HOME%\bin to the Path env. variable in windows.

  4. open CMD and cd to the folder where you have a pom.xml.

  5. Type: mvn package. 6. Post the output.

Thanks to @MarkBramnik

Anurag Rawal
  • 15
  • 1
  • 7