Maven安装成功后,总是无法成功mvn install?解决方法是JDK设置的问题。

[INFO] Changes detected - recompiling the module!
[INFO] Compiling 164 source files to G:\Maven\jfinal\target\classes
[INFO] -------------------------------------------------------------
[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: 03:24 min
[INFO] Finished at: 2017-04-24T19:26:25+08:00
[INFO] Final Memory: 13M/122M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jfinal_cms: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[ERROR] -> [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/MojoFailureException

G:\Maven\jfinal>

我重新执行mvn install,直接报错

G:\Maven\jfinal>mvn install
[INFO] Scanning for projects...
[WARNING]
[WARNING] Some problems were encountered while building the effective model for com.jflyfox:jfinal_cms:war:4.5.0
[WARNING] 'build.plugins.plugin.version' for org.apache.maven.plugins:maven-compiler-plugin is missing. @ line 162, column 12
[WARNING] The expression ${artifactId} is deprecated. Please use ${project.artifactId} instead.
[WARNING] The expression ${artifactId} is deprecated. Please use ${project.artifactId} instead.
[WARNING] The expression ${artifactId} is deprecated. Please use ${project.artifactId} instead.
[WARNING]
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
[WARNING]
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building jfinal_cms 4.5.0
[INFO] ------------------------------------------------------------------------
[WARNING] The POM for com.ibeetl:beetl:jar:2.7.11 is invalid, transitive dependencies (if any) will not be available, enable debug logging for more details
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ jfinal_cms ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 8 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ jfinal_cms ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 164 source files to G:\Maven\jfinal\target\classes
[INFO] -------------------------------------------------------------
[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: 1.179 s
[INFO] Finished at: 2017-04-24T19:31:02+08:00
[INFO] Final Memory: 10M/155M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jfinal_cms: Compilation failure
[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[ERROR]
[ERROR] -> [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/MojoFailureException

这个问题怎么都无法解决,重新在eclipse和myeclipse中重新配置JDK路径还是无法解决。

不知道是不是和我最开始嫌弃maven下载太慢,在maven目录中修改了setting.xml下载路径,换成aliyun端口。虽然貌似前几次下载依旧不成功,我反复尝试mvn install,结果就杯具了。。。。


-----------------------------------------------------分割线---------------------------------------------------------------

出现这个而问题之后我改变了一个思路来做,我重新设置了maven的本地仓库地址,把默认到C:\Users\hasee\.m2\repository的地址改成了我自己设置的地址:D:\Mavenm2\m2\repository;具体的修改方法看这两个引用链接:

http://www.cnblogs.com/liunanjava/archive/2015/11/05/4936037.html 或者http://xiaocao000.iteye.com/blog/1758639 这两篇博主的文章都可以,也许觉得不够详细,那么可以再参考百度问答的一个链接:https://zhidao.baidu.com/question/1769645808405821420.html

言归正传,这次我修改了本地仓库地址后,重新到项目文件下用控制台输入mvn install这次就没有报之前的错误,报出了一个新错误:

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 01:53 h
[INFO] Finished at: 2017-04-24T21:48:55+08:00
[INFO] Final Memory: 11M/127M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project jfinal_cms: Execution default-compile of goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile failed: 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-artifact:jar:2.0.9, org.apache.maven.shared:maven-shared-utils:jar:0.1, com.google.collections:google-collections:jar:1.0: Could not transfer artifact org.apache.maven:maven-artifact:jar:2.0.9 from/to central (https://repo.maven.apache.org/maven2): GET request of: org/apache/maven/maven-artifact/2.0.9/maven-artifact-2.0.9.jar from central failed: Read timed out -> [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/PluginResolutionException


没有想到竟然还是会报错。。。。。。。。。

修改maven目录conj下的setting.xml文件和本地仓库下的setting.xml文件中的:


    
                    

你可能感兴趣的:(【Java基础】)