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

来源:互联网 发布:4gip网络加速器 费用 编辑:程序博客网 时间:2024/05/21 11:06
[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/MojoFailureExceptionG:\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文件中的:

<profiles>    <!-- profile     | Specifies a set of introductions to the build process, to be activated using one or more of the     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>     | or the command line, profiles have to have an ID that is unique.     |     | An encouraged best practice for profile identification is to use a consistent naming convention     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.     | This will make it more intuitive to understand what the set of introduced profiles is attempting     | to accomplish, particularly when you only have a list of profile id's for debug.     |     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.    <profile>      <id>jdk-1.8</id>      <activation>        <jdk>1.8</jdk>      </activation>      <repositories>        <repository>          <id>jdk18</id>          <name>Repository for JDK 1.8 builds</name>          <url>http://www.myhost.com/maven/jdk18</url>          <layout>default</layout>          <snapshotPolicy>always</snapshotPolicy>        </repository>      </repositories>    </profile>

把其中的JDK版本全部修改成自己本机的JDK版本,不知道的可以控制台Java -version查看

修改完成之后我就把我的本机本地仓库中的maven下载清空,控制台到项目根目录直接mvn install,现在重新下载中:



希望这次可以成功啊

----------------------------------

这次果然成功了!!!


[INFO] Installing G:\Maven\jfinal\target\jfinal_cms.war to D:\Mavenm2\m2\repository\com\jflyfox\jfinal_cms\4.5.0\jfinal_cms-4.5.0.war[INFO] Installing G:\Maven\jfinal\pom.xml to D:\Mavenm2\m2\repository\com\jflyfox\jfinal_cms\4.5.0\jfinal_cms-4.5.0.pom[INFO] ------------------------------------------------------------------------[INFO] BUILD SUCCESS[INFO] ------------------------------------------------------------------------[INFO] Total time: 10:12 min[INFO] Finished at: 2017-04-25T14:27:06+08:00[INFO] Final Memory: 22M/156M[INFO] ------------------------------------------------------------------------

这次竟然成功了,困扰我两天的问题。

仔细思考了一下,这个问题的原因还是JDK的配置的问题,按照网上查出来的相关解决办法,我一步一步的来改变了Eclipse和Myeclipse中的maven设置和JDK路径;

依然出现项目目录下mvn -install不成功的情况;都是提示JDK版本不一致或者是没有JDK的运行环境;

我最后查看maven的配置文件setting.xml修改其中间的JDK配置, 按照本机的配置来,就没有报错了。

所以最后的解决办法是 再三确认JDK环境为何不能被Maven识别?????

1,要么就是eclipse和myeclipse中路径有问题;

2,要么就是POM.xml文件中JDK不匹配;

3,要么就是Maven目录和本地.m2本地仓库目录中的setting.xml中的JDK与本机JDK环境不匹配;

当然这三个前提是建立在确认JDK环境正确安装,环境变量都已经正确配置,Maven正确安装等这些情况下。

0 0
原创粉丝点击