How to fix Maven build issue in Eclipse? Perform maven-clean-install to fix any Java Dependency Issue

Last updated
App Shah

Crunchify » Eclipse IDE Tutorials » How to fix Maven build issue in Eclipse? Perform maven-clean-install to fix any Java Dependency Issue

Apache Maven is a Software Project Management tool. Based on the concept of a Project Object Model (POM), Maven can manage a project’s build, reporting and documentation from a central piece of information.

On Crunchify, we do have more than ~20 different maven tutorials including Setting up Maven Classpath on Windows and MacOS, maven-war-plugin, maven-shade-plugin, maven-assembly-plugin, etc.

In this tutorial we will go over highly and widely used some tips and tricks which will fix most of the Maven and POM dependency related issues for your in Eclipse IDE.

Below tips will work if you have any of below questions:

  • In Java how to fix Maven, Maven Configuration and Maven Dependency issue?
  • How do I update my Maven project to work in Eclipse?
  • maven dependency problem in eclipse
  • maven dependency problem eclipse missing artifact
  • How to fix error “Updating Maven Project”?
  • Maven Common Problems And Solutions

Let’s get started:

Task-1: Perform “Project Clean” in Eclipse IDE

Step-1

  • Create new maven based project or open existing maven project.
  • In my case, I’m opening my existing Simplest Spring MVC Hello World Project in Eclipse.

Step-2

  • Click on Project Menu item in Eclipse
  • Choose Clean... option from list
Eclipse Project Clean Option

Step-3

  • Select a project which you want to clean or Select All
  • In my case it’s just CrunchifySpringMVCTutorial
Select a Project which you want to clean in Eclipse IDE

Task-2: Perform Maven Update Project in Eclipse IDE

Step-4

  • Right click on Project
  • Click on Maven
  • Click on Update Project...
Perform Maven Update Project in Eclipse IDE

Task-3: Perform Maven clean install in Eclipse IDE

Step-5

  • Right click on project
  • Click on Run As
  • Click on Maven build...
mvn clean install in Eclipse IDE

Step-6

  • Provide Goal: mvn clean install
  • Select checkbox for Skip Tests
  • Click Apply and Run
Maven - mvn clean install Configuration Steps in Eclipse IDE

You should see BUILD SUCCESS message after successful run.

Build Success Message after mvn clean install

By performing above steps most of the common Maven build issues should be resolved in Eclipse. Let me know if you face any more issues and will try to debug.

Last Option:

Nothing worked and you are still getting weird Maven issue? Try deleting .m2/repository folder via File Explorer.

-> After that perform above steps and all maven libraries will be downloaded again fresh.

33 thoughts on “How to fix Maven build issue in Eclipse? Perform maven-clean-install to fix any Java Dependency Issue”

  1. Hi Sir,
    When I import existing maven project(simple spring MVC project) I am getting “Cannot access defaults field of Properties” in order to avoid this i added maven war plugin 3.3.1 in pom.xml it got solved and I tried maven clean install in eclipse the build got failed… I am using STS 4 with jdk 17… Could you help me with this one

    Reply
  2. [[1;34mINFO[m] Scanning for projects...
    [[1;33mWARNING[m] 
    [[1;33mWARNING[m] Some problems were encountered while building the effective model for com:SampleProject:jar:0.0.1-SNAPSHOT
    [[1;33mWARNING[m] 'dependencies.dependency.(groupId:artifactId:type:classifier)' must be unique: org.apache.poi:poi:jar -> duplicate declaration of version 4.1.2 @ line 53, column 13
    [[1;33mWARNING[m] 
    [[1;33mWARNING[m] It is highly recommended to fix these problems because they threaten the stability of your build.
    [[1;33mWARNING[m] 
    [[1;33mWARNING[m] For this reason, future Maven versions might no longer support building such malformed projects.
    [[1;33mWARNING[m] 
    [[1;34mINFO[m] 
    [[1;34mINFO[m] [1m---------------------------------------------------[m
    [[1;34mINFO[m] [1mBuilding SampleProject 0.0.1-SNAPSHOT[m
    [[1;34mINFO[m] [1m--------------------------------[ jar ]---------------------------------[m
    [[1;34mINFO[m] 
    [[1;34mINFO[m] [1m--- [0;32mmaven-resources-plugin:3.0.2:resources[m [1m(default-resources)[m @ [36mSampleProject[0;1m ---[m
    [[1;34mINFO[m] Using 'UTF-8' encoding to copy filtered resources.
    [[1;34mINFO[m] skip non existing resourceDirectory C:\Users\HP\eclipse-workspace\SampleProject\src\main\resources
    [[1;34mINFO[m] 
    [[1;34mINFO[m] [1m--- [0;32mmaven-compiler-plugin:3.8.0:compile[m [1m(default-compile)[m @ [36mSampleProject[0;1m ---[m
    [[1;34mINFO[m] Changes detected - recompiling the module!
    [[1;34mINFO[m] Compiling 9 source files to C:\Users\HP\eclipse-workspace\SampleProject\target\classes
    [[1;34mINFO[m] [1m------------------------------------------------------------------------[m
    [[1;34mINFO[m] [1;31mBUILD FAILURE[m
    [[1;34mINFO[m] [1m------------------------------------------------------------------------[m
    [[1;34mINFO[m] Total time:  1.920 s
    [[1;34mINFO[m] Finished at: 2022-12-20T19:15:16+05:30
    [[1;34mINFO[m] [1m------------------------------------------------------------------------[m
    [[1;31mERROR[m] Failed to execute goal [32morg.apache.maven.plugins:maven-compiler-plugin:3.8.0:compile[m [1m(default-compile)[m on project [36mSampleProject[m: [1;31mFatal error compiling[m: java.lang.IllegalAccessError: class lombok.javac.apt.LombokProcessor (in unnamed module @0x64b70f41) cannot access class com.sun.tools.javac.processing.JavacProcessingEnvironment (in module jdk.compiler) because module jdk.compiler does not export com.sun.tools.javac.processing to unnamed module @0x64b70f41 -> [1m[Help 1][m
    [[1;31mERROR[m] 
    [[1;31mERROR[m] To see the full stack trace of the errors, re-run Maven with the [1m-e[m switch.
    [[1;31mERROR[m] Re-run Maven using the [1m-X[m switch to enable full debug logging.
    [[1;31mERROR[m] 
    [[1;31mERROR[m] For more information about the errors and possible solutions, please read the following articles:
    [[1;31mERROR[m] [1m[Help 1][m http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
    Reply
  3. HI, I have error with build failure, below is that

    
    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/home/m.lavanya/Downloads/spring-tool-suite-4-4.9.0.RELEASE-e4.18.0-linux.gtk.x86_64/sts-4.9.0.RELEASE/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [file:/home/m.lavanya/Downloads/spring-tool-suite-4-4.9.0.RELEASE-e4.18.0-linux.gtk.x86_64/sts-4.9.0.RELEASE/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
    SLF4J: Class path contains multiple SLF4J bindings.
    SLF4J: Found binding in [jar:file:/home/m.lavanya/Downloads/spring-tool-suite-4-4.9.0.RELEASE-e4.18.0-linux.gtk.x86_64/sts-4.9.0.RELEASE/plugins/org.eclipse.m2e.maven.runtime.slf4j.simple_1.16.0.20200610-1735/jars/slf4j-simple-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: Found binding in [file:/home/m.lavanya/Downloads/spring-tool-suite-4-4.9.0.RELEASE-e4.18.0-linux.gtk.x86_64/sts-4.9.0.RELEASE/configuration/org.eclipse.osgi/5/0/.cp/org/slf4j/impl/StaticLoggerBinder.class]
    SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
    SLF4J: Actual binding is of type [org.slf4j.impl.SimpleLoggerFactory]
    [INFO] Scanning for projects...
    [INFO] 
    [INFO] ---------------------------
    [INFO] Building DataMungerStep5 0.0.1-SNAPSHOT
    [INFO] --------------------------------[ jar ]---------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  0.064 s
    [INFO] Finished at: 2020-12-26T16:28:58+05:30
    [INFO] ------------------------------------------------------------------------
    [ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format : or :[:]:. 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/LifecyclePhaseNotFoundException
    Reply
    • Hi Lavanya – this seems like an issue with mvn command.

      Could you please try without MVN? i.e. clean install instead of mvn clean install?

      Reply
  4. 
    [ERROR] COMPILATION ERROR : 
    [INFO] -------------------------------------------------------------
    [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    [INFO] 1 error
    [INFO] -------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  6.083 s
    [INFO] Finished at: 2020-09-08T02:43:30+05:30
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project Exam: Compilation failure
    [ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    [ERROR] -> [Help 1]
    org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project Exam: Compilation failure
    No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    
    
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:215)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:156)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:148)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:117)
        at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:81)
        at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:56)
        at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:128)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:305)
        at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:192)
        at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:105)
        at org.apache.maven.cli.MavenCli.execute(MavenCli.java:957)
        at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:289)
        at org.apache.maven.cli.MavenCli.main(MavenCli.java:193)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:282)
        at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:225)
        at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:406)
        at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:347)
    Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure
    No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
    
    
        at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1220)
        at org.apache.maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:187)
        at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:137)
        at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:210)
        ... 20 more
    [ERROR] 
    [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/MojoFailureException

    I got this type of error when try to build the project.

    Reply
    • Hi Sagar – could you please help share a screenshot of an error? It looks like you have just provided JRE as your classpath and not JDK.

      Make sure to add JDK to your class path and retry.

      Hope this helps.

      Reply
  5. hi sir, build is successfull but still i am getting error in pom.xml, i also deleted m2/reposiotry from file explorer,

    [INFO] Downloading: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar
    [INFO] Downloaded: https://repo.maven.apache.org/maven2/org/apache/maven/shared/maven-shared-utils/0.4/maven-shared-utils-0.4.jar (152 KB at 313.0 KB/sec)
    [INFO] Downloading: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.15/plexus-utils-3.0.15.jar
    [INFO] Downloaded: https://repo.maven.apache.org/maven2/org/codehaus/plexus/plexus-utils/3.0.15/plexus-utils-3.0.15.jar (234 KB at 392.2 KB/sec)
    [INFO] Installing C:UsersDellDownloadsdemotargetdemo-0.0.1-SNAPSHOT.jar to C:UsersDell.m2repositorycomexampledemo�.0.1-SNAPSHOTdemo-0.0.1-SNAPSHOT.jar
    [INFO] Installing C:UsersDellDownloadsdemopom.xml to C:UsersDell.m2repositorycomexampledemo�.0.1-SNAPSHOTdemo-0.0.1-SNAPSHOT.pom
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 01:22 min
    [INFO] Finished at: 2020-06-04T23:53:26-07:00
    [INFO] Final Memory: 32M/241M
    [INFO] ------------------------------------------------------------------------
    Reply
    • Hi Abinash – after build success message, please try refreshing your project. Error in pom.xml may be just a temporary issue.

      Reply
      • I am facing a problem while createing a maven project it take too long time and show somethimg dowloading but it look like stoped at point what i do

        Reply
  6. Hey Hi still I am getting this error after following your steps can help me to relove this?

    
    [INFO] Scanning for projects...
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building MavenR 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 0.209 s
    [INFO] Finished at: 2020-02-13T21:49:58+05:30
    [INFO] Final Memory: 5M/86M
    [INFO] ------------------------------------------------------------------------
    [WARNING] The requested profile "Skip" could not be activated because it does not exist.
    [WARNING] The requested profile "Tests" could not be activated because it does not exist.
    [ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format : or :[:]:. 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/LifecyclePhaseNotFoundException
    Reply
  7. APPLICATION FAILED TO START
    ***************************

    
    Description:
    
    Failed to bind properties under '' to com.zaxxer.hikari.HikariDataSource:
    
        Property: driverclassname
        Value: org.postgresql.Driver
        Origin: "driverClassName" from property source "source"
        Reason: Failed to load driver class org.postgresql.Driver in either of HikariConfig class loader or Thread context classloader
    
    Action:
    
    Update your application's configuration
    
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time:  17.715 s
    [INFO] Finished at: 2020-01-10T23:11:22+05:45
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:2.2.2.RELEASE:run (default-cli) on project demo: Application finished with exit code: 1 -> [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/MojoExecutionException

    what is the solution for this??

    Reply
    • Hi Shanti – can you please try running maven clean install again?

      Hope you have this dependency in your pom.xml:


      org.postgresql
      postgresql

      Usually this error caused by Maven downloading a corrupt version of the jar. Deleting it to force a new download fixed the issue.

      Reply
  8. Getting this error:

    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
    [INFO] Scanning for projects...
    [INFO]
    [INFO] ------------------------------------------------------------------------
    [INFO] Building CrunchifyTutorials 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 0.100s
    [INFO] Finished at: Tue Feb 13 15:51:55 IST 2018
    [INFO] Final Memory: 6M/121M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Unknown lifecycle phase "mvn". You must specify a valid lifecycle phase or a goal in the format : or :[:]:. 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/LifecyclePhaseNotFoundException
    Reply
  9. Unknown lifecycle phase “mvn”. You must specify a valid lifecycle phase or a goal in the format : or :[:]:. 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]

    Reply
  10. Unknown lifecycle phase “mvn”. You must specify a valid lifecycle phase or a goal in the format : or :[:]:. 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]

    Reply

Leave a Comment