褚留欢
2021-05-27 10:05
采纳率: 100%
浏览 64
已采纳

gradle编译spring源码报错

gradle编译spring源码报错,

Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 8m 55s
Build scan background action failed.
org.gradle.process.internal.ExecException: Process 'command 'git'' finished with non-zero exit value 128
        at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:417)
        at org.gradle.process.internal.DefaultExecAction.execute(DefaultExecAction.java:38)
        at org.gradle.process.internal.DefaultExecActionFactory.exec(DefaultExecActionFactory.java:168)
        at io.spring.ge.conventions.gradle.WorkingDirectoryProcessOperations.exec(WorkingDirectoryProcessOperations.java:45)
        at io.spring.ge.conventions.gradle.ProcessOperationsProcessRunner.run(ProcessOperationsProcessRunner.java:41)
        at io.spring.ge.conventions.core.BuildScanConventions.run(BuildScanConventions.java:166)
        at io.spring.ge.conventions.core.BuildScanConventions.addGitMetadata(BuildScanConventions.java:113)
        at io.spring.ge.conventions.gradle.GradleConfigurableBuildScan.lambda$background$0(GradleConfigurableBuildScan.java:104)
        at com.gradle.enterprise.gradleplugin.internal.extension.b$3.run(SourceFile:101)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
修改前:	
//repositories {
		//	mavenCentral()
	 	//	maven { url "https://repo.spring.io/libs-spring-framework-build" }
		//}
修改后:
		repositories {
			mavenCentral()
			maven { url "https://repo.spring.io/libs-spring-framework-build" }
			maven { url "https://repo.spring.io/snapshot" } // Reactor
			maven {url 'https://maven.aliyun.com/nexus/content/groups/public/'} //阿里云
			maven {url 'https://maven.aliyun.com/nexus/content/repositories/jcenter'}
		}
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

3条回答 默认 最新

  • 小P聊技术 2021-05-27 10:34
    已采纳

    此时编译Spring编码,Build -> Build Project
    可能会报如下错误:
    在这里插入图片描述
    这里查询问题的关键点是Process ‘command ‘git’’ finished with non-zero exit value 128,推出值为128,在百度寻找半天没有一个好的解决办法,然后谷歌找到问题所在,大部分解决方案都如下
    在这里插入图片描述
    其实看到这里就能发现问题,就是idea在调度终端时发生错误,找不到git,当然windows系统为cmd,但是mac默认并不是git终端,按照上述修改方式仍然无法解决问题,因为mac终端为:/bin/sh,所以下图才是找到问题的正解:
    在这里插入图片描述
    所以找到spring工程中gradle目录下找到build-scan-user-data.gradle
    将execAndGetStdout方法内容

    String execAndGetStdout(String... args) {
    	def stdout = new ByteArrayOutputStream()
    	exec {
    		commandLine(args)
    		standardOutput = stdout
    	}
    	return stdout.toString().trim()
    }
    

    替换为

    String execAndGetStdout(String... args) {
    	def stdout = new ByteArrayOutputStream()
    	exec {
    		executable "/bin/sh"
    		standardOutput = stdout;
    	}
    	return stdout.toString().trim()
    }
    

    然后再进行build,构建成功~
    在这里插入图片描述

    点赞 1 打赏 评论
  • 小P聊技术 2021-05-27 10:30

    看下你本地的git是否正确安装,如果没有的话,安装下,IDEA里面配置下

    点赞 打赏 评论
  • 有问必答小助手 2021-05-27 11:20

    您好,我是有问必答小助手,您的问题已经有小伙伴解答了,您看下是否解决,可以追评进行沟通哦~

    如果有您比较满意的答案 / 帮您提供解决思路的答案,可以点击【采纳】按钮,给回答的小伙伴一些鼓励哦~~

    ps:问答VIP仅需29元,即可享受5次/月 有问必答服务,了解详情>>>https://vip.csdn.net/askvip?utm_source=1146287632

    点赞 打赏 评论

相关推荐 更多相似问题