• 运行maven遇到的坑,差点崩溃了。


    参考链接1:https://blog.csdn.net/lch_cn/article/details/8225448/

    参考链接2:https://jingyan.baidu.com/article/ad310e80ef28c81849f49e16.html

    异常1:

    [ERROR] Failed to execute goal on project biz_zhuhai: Could not resolve dependencies for project biz_zhuhai:biz_zhuhai:jar:0.0.1-SNAPSHOT: Failed to collect dependencies for [com.maywide.ibh:lib345:pom:1.0 (compile)]: Failed to read artifact descriptor for com.maywide.ibh:lib345:pom:1.0: Could not transfer artifact com.maywide.ibh:lib345:pom:1.0 from/to releases (http://localhost:9888/nexus-2.0.3/content/repositories/releases): Connection to http://localhost:9888 refused: Connection refused: connect -> [Help 1]

    解决方法:

    这是配置的url有错误或者是私服没有配好,导致构件下载时出错。如果没有jar包需要在私服里下载,可以不配置私服的,也就是可以把setting.xml的profiles里的东西全部删除的。

    异常2:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.10:test (default-test) on project web_nanchang: There are test failures.

    [ERROR]

    [ERROR] Please refer to E:mavenweb_nanchang argetsurefire-reports for the individual test results.

    解决方法:

    这是因为测试代码时遇到错误,它会停止编译。只需要在pom.xml的<project>里添加以下配置,使得测试出错不影响项目的编译。

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <testFailureIgnore>true</testFailureIgnore>
                </configuration>
            </plugin>
        </plugins>
    </build>
     

    异常3:

    [ERROR] Failed to execute goal org.codehaus.cargo:cargo-maven2-plugin:1.0.6:start (start-container) on project myproject: Execution start-container of goal org.codehaus.cargo:cargo-maven2-plugin:1.0.6:start failed: Error while expanding C:DOCUME~1ADMINI~1LOCALS~1Tempcargoinstallsapache-tomcat-6.0.29.zip
    [ERROR] java.io.IOException: Negative seek offset
    [ERROR] -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e swit
    ch.
    [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 rea
    d the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutio
    nException

    解决方法:

    自己下载“apache-tomcat-6.0.29.zip”,将下载好的文件拷贝到指定文件夹“C:Documents and SettingsAdministratorLocal SettingsTempcargoinstalls”下。

    异常4:

    [ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.1.1:war (default-war) on project web_nanchang: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [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:

    解决方法:

    maven的web项目默认的webroot是在srcmainwebapp。如果在此目录下找不到web.xml就抛出以上的异常。解决方法在pom.xml加入以下的配置。红色字体改成你网站的根目录。

    <build>
        <finalName>simple-webapp</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>2.1.1</version>
                <configuration>
                    <webResources>
                        <resource>
                            <!-- this is relative to the pom.xml directory -->
                            <directory>WebContent</directory>
                        </resource>
                    </webResources>
                </configuration>
            </plugin>
        </plugins>
    </build>

    Maven下载jar包出现.lastUpdated结尾的文件问题及解决

    原文链接:https://blog.csdn.net/qq784515681/article/details/88739188

    出错原因

    出现.lastUpdated结尾的文件的原因:由于网络原因没有将Maven的依赖下载完整导致。

    解决方案:

    有私服地址的情况下:

    1、删除所有以.lastUpdate结尾的文件

    a) 切换到maven的本地仓库

    b) 在当前目录打开cmd命令行

    c) Windows执行命令:for /r %i in (*.lastUpdated) do del %i

    d) Linux执行命令:

    find /app/maven/localRepository -name "*.lastUpdated" -exec grep -q "Could not transfer" {} ; -print -exec rm {} ;

    补充:

    IntelliJ IDEA如何重新下载已删除的maven依赖包?

    右键项目 -》 下拉找到Maven -》 选择Reimport即可。

    第二个解决jar包无法加载的问题。


    第一个方法:删除本地的 epository库中所有.lastupdate后缀文件 以及sha1-in-progress为后缀的文件,重新下载
     当我们使用eclipse下载jar包,有事突然退出,再次进入jar包还是下载不起

         可能的原因就是 maven没有将jar下载完时,会生成一个.lastupdate文件

         在校验sha1码未完成时会生成sha1-in-progress为后缀的文件

         解决方法: 使用文件搜索工具(楼主用的是 Everything) 输入.lastupdate删除所有以.lastupdate结尾的文件;

          输入sha1-in-progress删除所有以sha1-in-progress结尾的文件。

    然后简单修改.pom(比如加空格) 保存,然后eclipse就会重新下载jar包!

      第二个办法:maven添加镜像地址,编辑maven根目录中conf文件夹下settings.xml
     

    在 mirrors中增加

    <mirrors>  

        <mirror>  
               <id>ibiblio.org</id>  
               <name>ibiblio Mirror of http://repo1.maven.org/maven2/</name>  
               <url>http://mirrors.ibiblio.org/pub/mirrors/maven2</url>  
               <mirrorOf>central</mirrorOf>  
               <!-- United States, North Carolina -->  
         </mirror>  
         <mirror>  
             <id>jboss-public-repository-group</id>  
             <mirrorOf>central</mirrorOf>  
             <name>JBoss Public Repository Group</name>  
             <url>http://repository.jboss.org/nexus/content/groups/public</url>  
         </mirror>  
      </mirrors></span>  
         添加保存后,重新编辑pom文件,加个空格什么的,能下载部分jar包,还是有一些jar不能下载

      第三个办法:拷贝相应jar,手动导入本地库
     

    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context-support</artifactId>
        <version>3.1.0.RELEASE</version>
    </dependency>

    Maven 安装 JAR 包的命令是:
     

      mvn install:install-file -Dfile=jar包的位置 -DgroupId=上面的groupId -DartifactId=上面的artifactId -Dversion=上面的version -Dpackaging=jar

    如何手动获取jar包,

    1、通过 在http://mvnrepository.com/中查询到相应的jar包的, 如查询  Sqljdbc4

    2、得到如下的maven

    <!-- https://mvnrepository.com/artifact/com.microsoft.sqlserver/sqljdbc4 -->
    <dependency>
    <groupId>com.microsoft.sqlserver</groupId>
    <artifactId>sqljdbc4</artifactId>
    <version>4.0</version>
    <scope>test</scope>
    </dependency>

    可以通过输入http://clojars.org/repo/ 到浏览器,通过groupId 和 artifactId以及版本号,查询到jar包,然后下载到本地即可

    linux下

    ~/.m2 -name "*.lastUpdated" -exec grep -q "Could not transfer" {} ; -print -exec rm {} ;
     
    cd %userprofile%.m2 epository
    for /r %i in (*.lastUpdated) do del %i
    然后右击你的工程,Maven->”Update Project …”,即可解决。
    ---------------------
    作者:ckxuexixuexi
    来源:CSDN
    原文:https://blog.csdn.net/ckxuexixuexi/article/details/80824203

  • 相关阅读:
    node.js简单的服务器
    简单的分页1
    定时跳转
    初始化多个vue实例对象
    js获取验证码的方法
    [z]Java代理(jdk静态代理、动态代理和cglib动态代理)
    .net操作word lib DocX
    git常用命令
    [z]查表空间使用情况
    [z]oracle job
  • 原文地址:https://www.cnblogs.com/qcq0703/p/10964176.html
Copyright © 2020-2023  润新知