build.gradle报错(eclipse编译不了项目)

2022-07-28 11:01:39 浏览数 (1)

大家好,又见面了,我是你们的朋友全栈君。

笔者是通过idea编译spring5源代码,该项目基于gradle构建,编译过程中具体报错如下:
代码语言:javascript复制
2020-03-16 10:38:26,134 [ 663812]   INFO - .project.GradleProjectResolver - Gradle project resolve error 
org.gradle.tooling.GradleConnectionException: Could not run build action using Gradle installation 'D:Program Filesgradle-4.3.1'.
	at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:55)
	at org.gradle.tooling.internal.consumer.ExceptionTransformer.transform(ExceptionTransformer.java:29)
	at org.gradle.tooling.internal.consumer.ResultHandlerAdapter.onFailure(ResultHandlerAdapter.java:41)
	at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:57)
	at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
	at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
	at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: org.gradle.launcher.daemon.client.DaemonConnectionException: The newly created daemon process has a different context than expected.
It won't be possible to reconnect to this daemon. Context mismatch: 
Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=D:Program FilesJavajdk1.8.0_221,daemonRegistryDir=E:UsersMatch.gradledaemon,pid=10004,idleTimeout=null,daemonOpts=-XX: HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]
Actual: DefaultDaemonContext[uid=a2c59eee-3795-4a86-b42a-467354d02f2e,javaHome=D:Program FilesJavajdk1.8.0_221jre,daemonRegistryDir=E:UsersMatch.gradledaemon,pid=6168,idleTimeout=10800000,daemonOpts=-XX: HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]

	at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connectToDaemonWithId(DefaultDaemonConnector.java:244)
	at org.gradle.launcher.daemon.client.DefaultDaemonConnector.doStartDaemon(DefaultDaemonConnector.java:215)
	at org.gradle.launcher.daemon.client.DefaultDaemonConnector.startDaemon(DefaultDaemonConnector.java:204)
	at org.gradle.launcher.daemon.client.DefaultDaemonConnector.connect(DefaultDaemonConnector.java:128)
	at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:138)
	at org.gradle.launcher.daemon.client.DaemonClient.execute(DaemonClient.java:92)
	at org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:60)
	at org.gradle.tooling.internal.provider.DaemonBuildActionExecuter.execute(DaemonBuildActionExecuter.java:41)
	at org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:60)
	at org.gradle.tooling.internal.provider.LoggingBridgingBuildActionExecuter.execute(LoggingBridgingBuildActionExecuter.java:34)
	at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:143)
	at org.gradle.tooling.internal.provider.ProviderConnection.run(ProviderConnection.java:128)
	at org.gradle.tooling.internal.provider.DefaultConnection.run(DefaultConnection.java:212)
	at org.gradle.tooling.internal.consumer.connection.CancellableActionRunner.execute(CancellableActionRunner.java:63)
	at org.gradle.tooling.internal.consumer.connection.CancellableActionRunner.run(CancellableActionRunner.java:51)
	at org.gradle.tooling.internal.consumer.connection.AbstractConsumerConnection.run(AbstractConsumerConnection.java:63)
	at org.gradle.tooling.internal.consumer.connection.ParameterValidatingConsumerConnection.run(ParameterValidatingConsumerConnection.java:54)
	at org.gradle.tooling.internal.consumer.DefaultBuildActionExecuter$1.run(DefaultBuildActionExecuter.java:76)
	at org.gradle.tooling.internal.consumer.connection.LazyConsumerActionExecutor.run(LazyConsumerActionExecutor.java:84)
	at org.gradle.tooling.internal.consumer.connection.CancellableConsumerActionExecutor.run(CancellableConsumerActionExecutor.java:45)
	at org.gradle.tooling.internal.consumer.connection.ProgressLoggingConsumerActionExecutor.run(ProgressLoggingConsumerActionExecutor.java:58)
	at org.gradle.tooling.internal.consumer.connection.RethrowingErrorsConsumerActionExecutor.run(RethrowingErrorsConsumerActionExecutor.java:38)
	at org.gradle.tooling.internal.consumer.async.DefaultAsyncConsumerActionExecutor$1$1.run(DefaultAsyncConsumerActionExecutor.java:55)
	... 6 more
2020-03-16 10:38:26,135 [ 663813]   INFO - System.util.ExternalSystemUtil - External project [E:/Users/Match/Documents/WorkSpace/IdeaProjects/GitHub/spring-projects/spring-framework] resolution task executed in 3221 ms. 
2020-03-16 10:38:26,135 [ 663813]   WARN - ernalSystemProjectsWatcherImpl - The newly created daemon process has a different context than expected.
It won't be possible to reconnect to this daemon. Context mismatch: 
Java home is different.
Wanted: DefaultDaemonContext[uid=null,javaHome=D:Program FilesJavajdk1.8.0_221,daemonRegistryDir=E:UsersMatch.gradledaemon,pid=10004,idleTimeout=null,daemonOpts=-XX: HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]
Actual: DefaultDaemonContext[uid=a2c59eee-3795-4a86-b42a-467354d02f2e,javaHome=D:Program FilesJavajdk1.8.0_221jre,daemonRegistryDir=E:UsersMatch.gradledaemon,pid=6168,idleTimeout=10800000,daemonOpts=-XX: HeapDumpOnOutOfMemoryError,-Xmx1024m,-Dfile.encoding=GBK,-Duser.country=CN,-Duser.language=zh,-Duser.variant]
经过上网搜索,很多解决方案给出的都是重命名本地JAVA_HOME/lib下的tools.jar,编译完成之后再恢复原名,笔者尝试之后依旧不能解决问题,
又有一种解决方案是在项目目录下的gradle.properties中配置java home,笔者直接复制java home路径配置,发现还是报如下错误:
代码语言:javascript复制
FAILURE: Build failed with an exception.

* What went wrong:
Value 'D:Program FilesJavajdk1.8.0_221' given for org.gradle.java.home Gradle property is invalid (Java home supplied is invalid)

* Try:
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
仔细观察发现路劲中的 都不见了,笔者猜想程序是把 当作转义符处理,故将路径中的单斜杠都替换成双斜杠,程序成功编译,配置如下:
代码语言:javascript复制
version=5.0.17.BUILD-SNAPSHOT
org.gradle.java.home=D:\Program Files\Java\jdk1.8.0_221
配置之后再编译如下

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/128415.html原文链接:https://javaforall.cn

0 人点赞