Maven 打包 Perhaps you are running on a JRE rather than a JDK?

Mavnen 报错记录,公司电脑和家里电脑idea版本不同,暂未解决

公司电脑---->mvn命令编译失败,直接启动失败, 启动方式 先compile 使用lifeycle编译,然后在使用package 这样是可以编译通过,打出来jar包的,勉强算是启动成功
在这里插入图片描述

  1. IDEA版本 2020 无法使用右侧 maven install 编译成jar包和war包 执行代码时会报错
  2. maven版本 apache-maven-3.6.1
  3. 使用配置的本地maven仓库

家里电脑----->依然使用mvn clean install 命令是可以编译打包成功的 ,启动ok
其实就idea版本和公司不同

值得注意的是这里是使用mvn在cmd中打包的 在idea中打包依然会报错 错误最下图

在这里插入图片描述

  1. IDEA版本2018.2
  2. maven版本 apache-maven-3.6.1
  3. 使用配置的本地maven仓库

在idea中使用命令打包

[INFO] --------------------------------[ jar ]---------------------------------
[INFO] 
[INFO] --- maven-install-plugin:2.4:install (default-cli) @ b-xxxx---
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for b-parent 1.0:
[INFO] 
[INFO] axxxx........................................... SUCCESS [  0.374 s]
[INFO] axxxx............................................ FAILURE [  0.007 s]
[INFO] axx............................................    SKIPPED
[INFO] axx.............................................. SKIPPED
[INFO] xxxx..........................................     SKIPPED
[INFO] xxxxxx.............................................. SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.769 s
[INFO] Finished at: 2020-11-09T21:48:31+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-install-plugin:2.4:install (default-cli) on project b-utils: The packaging for this project did not assign a file to the build artifact -> [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] 
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :b-utils

Process finished with exit code 1

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  0.860 s
[INFO] Finished at: 2020-11-12T09:57:58+08:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project xxxxxxx: 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
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <goals> -rf :b-utils

找到解决办法了!!!

https://www.xinke.org.cn/article/detail/775

1 . 在maven的setting.xml 文件 标签中加入指定JDK的版本\

D:\ProgramFiles\maven\apache-maven-3.6.1\conf/settings.xml

<profile>     
      <id>JDK-1.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>

  1. pom文件添加
 <build>
		<plugins>
			<plugin>
				<artifactId>maven-compiler-plugin</artifactId>
				<version>3.6.1</version>
				<configuration>
					<fork>true</fork>
					<executable>
						C:\Program Files\Java\jdk1.8.0_211\bin\javac.exe
					</executable>
				</configuration>
			</plugin>
		</plugins>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值