When Java-Eclipse imports a maven project, the Pom.xml file reports an error handling method

When Eclipse imports a maven project, the Pom.xml file reports an error handling method

Import the maven project, FIle→Import→Existing Maven Projects→find the file directory you want to import→Finish. The project is imported. Then encountered various errors! !

First, the Pom.xml file reports an error for the first time

CoreException: Could not get the value for parameter compilerId for plugin execution default-testCompile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-plugin-api:jar:2.0.9, org.apache.maven:maven-artifact:jar:2.0.9, org.apache.maven:maven-core:jar:2.0.9: Failure to transfer org.apache.maven:maven-plugin-api:jar:2.0.9 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-plugin-api:jar:2.0.9 from/to central (https://repo.maven.apache.org/maven2): connect timed out。

Solution:

This is because of network reasons, resulting in the file not being downloaded.

Search for xxx.jar.lastUpdated on the computer and delete all of them. The specific steps are as follows:

1) Find {user}/.m2/repository

2) Search for ".lastupdated". (If you don't remember the corresponding .m2 location, you can search the whole computer) Windows will display the directory of all folders.

3) Select the corresponding lastupdated file and delete it.

4) Re-open (if it has not been closed before, please close and reopen) Eclipse, right-click the project where the error is reported, and select Maven > Update Project. Also remember to check "Force Update of Snapshots/Releases". Click OK and the dependencies are resolved.


2. The Pom.xml file reports an error again

[ERROR] No goals have been specified for this build. 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/NoGoalSpecifiedException

Solution:

Right-click the project that reported the error → Properties → Project Facets → Runtimes → check Apache Tomcat v7.0

When you cannot find Runtimes at Project Facets, you need to click Convert to faceted from…







3. Pox.xml finally reported an error

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project mrpapp: Compilation failure

[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

Solution:

Find Window → Preferences → Java → Installed JREs in eclipse, and change it to the directory location of your installed jdk in jRE home.




Well, all 3 errors have been handled, and now I can run the project happily!


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324883883&siteId=291194637