溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

常見的Maven報(bào)錯(cuò)原因是什么及怎么解決

發(fā)布時(shí)間:2022-09-28 11:18:21 來源:億速云 閱讀:665 作者:iii 欄目:服務(wù)器

這篇文章主要介紹“常見的Maven報(bào)錯(cuò)原因是什么及怎么解決”的相關(guān)知識(shí),小編通過實(shí)際案例向大家展示操作過程,操作方法簡單快捷,實(shí)用性強(qiáng),希望這篇“常見的Maven報(bào)錯(cuò)原因是什么及怎么解決”文章能幫助大家解決問題。

報(bào)錯(cuò):No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?

解決方法

問題是將JRE作為JDK使用了,解決辦法是安裝JDK,并將JDK設(shè)置到Installed JREs中

圖示

常見的Maven報(bào)錯(cuò)原因是什么及怎么解決

常見的Maven報(bào)錯(cuò)原因是什么及怎么解決

錯(cuò)誤堆棧

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project hibernate: Compilation failure[ERROR] No compiler is provided in this environment. Perhaps you are running on a JRE rather than a JDK?
[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

Failed to transfer http://xx.xx. Error code 400, Repository version policy: RELEASE does not allow metadata in path: cn/blueboz/train/hibernate/0.0.1-SNAPSHOT/maven-metadata.xml -> [Help 1]

問題原因

如果是deploy 出現(xiàn)問題,那么可能是因?yàn)閷⒉渴鹇窂綄戝e(cuò),如本例子,錯(cuò)誤在于將SNAPSHOT版本寫成RELEASE版本

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project hibernate: Failed to retrieve remote metadata cn.blueboz.train:hibernate:0.0.1-SNAPSHOT/maven-metadata.xml: Could not transfer metadata cn.blueboz.train:hibernate:0.0.1-SNAPSHOT/maven-metadata.xml from/to blueboz-snapshots (http://bluebozpc:8081/repository/maven-releases): Failed to transfer http://bluebozpc:8081/repository/maven-releases/cn/blueboz/train/hibernate/0.0.1-SNAPSHOT/maven-metadata.xml. Error code 400, Repository version policy: RELEASE does not allow metadata in path: cn/blueboz/train/hibernate/0.0.1-SNAPSHOT/maven-metadata.xml -> [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

#

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project hibernate: Failed to deploy artifacts: Could not transfer artifact cn.blueboz.train:hibernate:jar:0.0.1-20170319.142156-1 from/to blueboz-snapshots (http://bluebozpc:8081/repository/maven-snapshots): Access denied to http://bluebozpc:8081/repository/maven-snapshots/cn/blueboz/train/hibernate/0.0.1-SNAPSHOT/hibernate-0.0.1-20170319.142156-1.jar. Error code 401, Unauthorized -> [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

新建項(xiàng)目卡頓問題

常見的Maven報(bào)錯(cuò)原因是什么及怎么解決

將maven的配置設(shè)置為offline,離線更新就可以了

常見的Maven報(bào)錯(cuò)原因是什么及怎么解決

Fail to transfer …錯(cuò)誤

Failure to transfer 
    org.codehaus.plexus:plexus-archiver:jar:3.4
    was cached in the local repository, 
    resolution will not be reattempted until 
    the update interval of [Bsdn] has elapsed or updates are forced. 
    Original error: 
         org.codehaus.plexus:plexus-archiver:jar:3.4 
    Bsdn (http://nexus.bsdn.org/content/groups/public/):    No response received after 60000

一般是因?yàn)閚exus 私服鏈接超時(shí),建議直接換一個(gè)私服即可,在用戶路徑下的setting中,修改成aliyun的私服

 <mirror>
  <id>Alibaba</id>
  <mirrorOf>central</mirrorOf>
  <name>AliyunMaven</name>
  <url>http://maven.aliyun.com/nexus/content/groups/public/</url></mirror>

實(shí)在不行的話,根據(jù)GAV,定位到本地緩存目錄,將

\M2_HOME.m2\repository\org\codehaus\plexus\plexus-archiver\3.4

目錄下的資源刪掉,重新UpdateProject即可

Update Project 的時(shí)候變成J2SE1.4

這個(gè)問題,網(wǎng)上提供了兩種方案先給出代碼,如果嘗試了之后發(fā)現(xiàn)可以的話,請(qǐng)按照這種方式解決。如果還是不行,請(qǐng)看我的第三種終極解決方案

1.解決方法一

$HOME目錄下的.m2目錄下的settings.xml文件的profiles節(jié)點(diǎn)下添加如下信息。Jdk版本

<profile>   
    <id>jdk1.8</id>    
    <activation>   
        <activeByDefault>true</activeByDefault>    
        <jdk>1.8</jdk>   
    </activation>    
    <properties>   
        <maven.compiler.source>1.8</maven.compiler.source>    
        <maven.compiler.target>1.8</maven.compiler.target>    
        <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>   
    </properties>   </profile>

2.解決方法二

在 build->pluginManager下添加,或修改maven-compiler-plugin的默認(rèn)配置信息

<plugin>
    <artifactId>maven-compiler-plugin</artifactId>
    <version>3.7.0</version>
    <configuration>
        <source>1.8</source>
        <target>1.8</target>
    </configuration></plugin>

3.更新插件方法

必須前面兩個(gè)方法都嘗試了之后,還是無效的情況下。才可以。這時(shí)候,你必須考慮是不是你的IDE的問題了。筆者使用的是EclipseKepler版本,最高支持Jdk7。

點(diǎn)擊進(jìn)入EclipseMarketPlace,輸入Maven

JavaTm 8 support for m2e for Eclipse Kepler SR2 ,安裝就可以了,建議還是翻墻安裝快些

常見的Maven報(bào)錯(cuò)原因是什么及怎么解決

關(guān)于“常見的Maven報(bào)錯(cuò)原因是什么及怎么解決”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí),可以關(guān)注億速云行業(yè)資訊頻道,小編每天都會(huì)為大家更新不同的知識(shí)點(diǎn)。

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI