maven常见错误

问题描述

  • 错误1:maven打包报错
  • 错误还原:使用maven打包项目时报错如下
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project helloworld: Input length = 1 -> [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

  • 解决方案:配置pom.xml中的maven插件
<plugin>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-resources-plugin</artifactId>
    <version>3.1.0</version>
</plugin>
  • 参考

  • 错误2:打包项目时报错:maven--Error executing Maven. 2 problems were encountered while building the effective settings

# 参考:https://blog.csdn.net/weixin_45406850/article/details/117856833
# 解决方案:settings.xml中标签是否一一对应
<localRepository>E:\apache-maven-3.6.3\repo</localRepository>
<mirrors>
  <mirror>
    <id>alimaven</id>
    <mirrorOf>central</mirrorOf>
    <name>aliyun maven</name> 
    <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  </mirror>
</mirrors>
<profiles>
	<profile>
    <id>alibaba</id>
    <activation>
      <activeByDefault>true</activeByDefault>
      <jdk>11</jdk>
    </activation>
    <properties>
      <maven.compiler.source>11</maven.compiler.source>
      <maven.compiler.target>11</maven.compiler.target>
      <maven.compiler.compilerVersion>11</maven.compiler.compilerVersion>
    </properties>
  </profile>
</profiles>
  • 错误3:maven拉取依赖失败,本地仓库中只能下载 .lastUpdate后缀的文件
错误原因:由于我本地安装了jdk8和jdk14,所以当切换jdk的时候;maven的setting.xml中也需重新配置jdk的版本
解决方案:写一个脚本删除所有 .lastUpdate后缀的文件,重新配置setting.xml后重新拉去依赖
脚本:clearLastUpdated.bat

@echo off
rem create by NettQun 
rem 这里写你的仓库路径
set REPOSITORY_PATH=C:\Users\LENOVO\.m2\repository
rem 正在搜索...
for /f "delims=" %%i in ('dir /b /s "%REPOSITORY_PATH%\*lastUpdated*"') do (
    echo %%i
    del /s /q "%%i"
)
rem 搜索完毕
pause

# 执行完脚本后,重写配置setting.xml,重新拉取依赖

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...