我正在尝试编译下面的代码Gralde 4.9、Groovy-2.5.2和JDK11,它给出了这个错误,相同的代码在JDK 8中编译。
import groovy.util.logging.Slf4j
import org.apache.http.HttpEntity
import org.apache.http.client.methods.CloseableHttpResponse
import org.apache.http.client.methods.HttpPost
import org.apache.http.entity.ContentType
import org.apache.http.entity.mime.MultipartEntityBuilder
import org.apache.http.entity.mime.content.FileBody
import org.apache.http.entity.mime.content.StringBody
import org.apache.http.impl.client.CloseableHttpClient
import org.apache.http.impl.client.HttpClients
import org.apache.http.util.EntityUtils
import picocli.CommandLine
import picocli.CommandLine.Command
import picocli.CommandLine.Option
@Command(name = "FileUpload", version = "File Upload 0.1", mixinStandardHelpOptions = true, description = "@|bold Groovy|@ @|underline picocli|@ example")
@Slf4j
class FileUpload implements Runnable {
@Option(names = ["-u", "--url"], paramLabel = "<URL>", description = "URL to upload")
String url
@Option(names = ["-f", "--filename"], paramLabel = "<FILENAME>", description = "filename to upload")
String filename
@Option(names = ["-d", "--debug"], description = "Enable Debug")
String debug
void run() {
if (debug) {
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
System.setProperty("org.apache.commons.logging.simplelog.showdatetime", "true");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.wire", "DEBUG");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.impl.conn", "DEBUG");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.impl.client", "DEBUG");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http.client", "DEBUG");
System.setProperty("org.apache.commons.logging.simplelog.log.org.apache.http", "DEBUG");
}
if (!filename || !new File(filename).exists()) {
log.info( "File name argument missing, or File not found $filename")
usage()
return
}
if (!url) {
log.info( "URL required")
usage()
return
}
upload(url, filename)
}
def static void main(args) {
CommandLine.run(new FileUpload(), args)
}
def static usage(){
println '''
Usage: FileUpload -u http://webserver/home/upload -f c1.csv
'''
}
public static void upload(url, filename) throws Exception {
if (!new File(filename).exists()) {
System.out.println("File path not given");
System.exit(1);
}
CloseableHttpClient httpclient = HttpClients.createDefault();
try {
HttpPost httppost = new HttpPost(url);
File f = new File(filename)
FileBody bin = new FileBody(f);
StringBody comment = new StringBody("A binary file of some kind", ContentType.TEXT_PLAIN);
HttpEntity reqEntity = MultipartEntityBuilder.create()
.addPart("filename", bin)
.addPart("filename1", new StringBody(f.getName()))
.addPart("comment", comment)
.build();
httppost.setEntity(reqEntity);
log.info("executing request " + httppost.getRequestLine());
CloseableHttpResponse response = httpclient.execute(httppost);
try {
log.info("----------------------------------------");
log.info(response.getStatusLine().toString());
println(response.getStatusLine());
log.info("----------------------------------------");
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
log.info("Response content length: " + resEntity.getContentLength());
}
EntityUtils.consume(resEntity);
} finally {
response.close();
}
} finally {
httpclient.close();
}
}
}
错误消息
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':compileGroovy'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77)
at org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)
at org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44)
at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91)
at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.run(EventFiringTaskExecuter.java:51)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)
at org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174)
at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46)
at org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:273)
at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:258)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:135)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker$1.execute(DefaultTaskPlanExecutor.java:130)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor$ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)
at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by: BUG! exception in phase 'semantic analysis' in source unit 'FileUpload.groovy' null
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:179)
at org.gradle.api.internal.tasks.compile.ApiGroovyCompiler.execute(ApiGroovyCompiler.java:57)
at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:77)
at org.gradle.api.internal.tasks.compile.GroovyCompilerFactory$DaemonSideCompiler.execute(GroovyCompilerFactory.java:65)
at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerCallable.call(AbstractDaemonCompiler.java:88)
at org.gradle.api.internal.tasks.compile.daemon.AbstractDaemonCompiler$CompilerCallable.call(AbstractDaemonCompiler.java:76)
at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:42)
at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:46)
at org.gradle.workers.internal.WorkerDaemonServer.execute(WorkerDaemonServer.java:30)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.process.internal.worker.request.WorkerAction.run(WorkerAction.java:101)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:155)
at org.gradle.internal.remote.internal.hub.MessageHubBackedObjectConnection$DispatchWrapper.dispatch(MessageHubBackedObjectConnection.java:137)
at org.gradle.internal.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:404)
... 3 more
Caused by: java.lang.UnsupportedOperationException
at groovyjarjarasm.asm.ClassVisitor.visitNestMemberExperimental(ClassVisitor.java:248)
at groovyjarjarasm.asm.ClassReader.accept(ClassReader.java:651)
at groovyjarjarasm.asm.ClassReader.accept(ClassReader.java:391)
我在这里有github项目:https://github.com/sfgroups/FileUpload
看来你遇到https://issues.apache.org/jira/browse/GROOVY-8727.
经过多次搜索并试图解决这个问题,最终我不能,当我试图在真正的手机上运行应用程序时,我得到这个错误: 失败:构建失败,但有例外。 出了什么问题:无法打开设置文件“C:\项目\扑腾\埃尔穆斯塔法\android\settings.gradle”的设置通用类缓存(C:\用户\Mahdi MyName.gradle\caches\6.5\scripts\bq3hllkgb26p0nrblf5gh8d37\
请帮我解决这个问题。我试图在我的真实设备上运行我的第一个项目,但我得到了这个错误:失败:构建失败,出现异常。 < li >哪里出错:无法打开设置文件“C:\ Users \ Admin \ AndroidStudioProjects \ flutter _ first app \ Android \ settings . gradle”(C:\ Users \ Admin . gradle \ c
我有一个使用Gradle1.10和JDK1.8的1.1.7 spring-boot应用程序。我使用Groovy/Spock测试它有两个依赖项--用Apache Maven 3.1.1和JDK1.8构建JAR。我构建JAR,然后他们将它们复制到/lib目录中。然后我试着用“Gradle clean build”建造。 以下是我的分级文件的一部分:
我试图使用gradle创建一个新的Java9项目,但就在项目创建后,我收到了gradle的错误: Java版本:9(构建9+178) Gradle版本:4.1-RC-2 根据本文,那些Java/Gradle版本应该是兼容的。 我如何解决这个问题? 非常感谢任何帮助。
我试图弄明白,但我甚至找不到方法。请帮帮我。 当我尝试运行我的第一个颤振应用程序时,会发生以下情况: 我已经用物理设备和模拟器进行了尝试。我试着用“颤振清洁”。振作起来,医生,说一切都好。 如果有帮助的话,下面是运行“颤振跑-v”时的结果: 求你了,我真的需要帮助。
问题内容: 我正在尝试使用 gradle* 创建一个新的 Java 9 项目,但是在项目创建之后,我立即收到了来自gradle的错误消息: * Java版本:9(内部版本9 + 178) Gradle版本:4.1-rc-2 根据该文章这些Java / gradle这个版本应该是兼容的。 我怎么解决这个问题? 任何帮助表示高度赞赏。 问题答案: 我已通过将Gradle JVM降级到8解决了该问题。这