使用gradle加载命令行属性,但找不到方法execSpec() [英] Using gradle to load command line properties but cannot find method execSpec()

查看:148
本文介绍了使用gradle加载命令行属性,但找不到方法execSpec()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图按照将命令行系统属性委托给spring-boot-gradle-plugin runApp任务#592

我的gradle构建文件的一部分是

Part of my gradle build file is

apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
apply plugin: 'jacoco'
apply plugin: 'docker'

bootRun {
  execSpec {
    systemProperty 'com.example.foo', 'bar'
  }
}

我收到一条错误消息

Could not find method execSpec() for arguments [build_48hmmm554of8gjd2p2pou6vn0$_run_closure5$_closure17@30ae2373] on task ':bootRun' of type org.springframework.boot.gradle.run.BootRunTask.

如何加载execSpec()?

How do I load execSpec()?

推荐答案

从Spring Boot 2.0.0开始,execSpec应该在bootRun中工作.但是我今天遇到了同样的问题.奇怪的是,它一会儿就起作用了,而在我更改项目名称后几秒钟后就停止了工作. 我意识到此更改触发了Gradle刷新,并且之后以某种方式在我的gradle缓存中有两个不同的spring-boot-gradle-plugin-2.0.0.BUILD-SNAPSHOT.jar版本. On是57 kb,其他58 kb.我解开了罐子的包装,调查了内容,发现区别完全是类org.springframework.boot.gradle.tasks.run.BootRun,一个类为3 kb,另一个版本为7 kb.因此,我认为57 kb版本缺少execSpec.

As of Spring Boot 2.0.0 execSpec should work in bootRun. However I ran into the same problem today. The strange thing is, it worked at one moment and stopped working some seconds later after I changed my project name. I realised that this change triggered a Gradle refresh and somehow afterwards there were two different versions of spring-boot-gradle-plugin-2.0.0.BUILD-SNAPSHOT.jar in my gradle cache. On is 57 kb and the other 58 kb. I unpacked the jars, looked into the content and found out that the difference is exactly the class org.springframework.boot.gradle.tasks.run.BootRun, which is 3 kb in the one and 7 kb in the other version. So I guess the 57 kb version lacks execSpec.

然后我直接检查了Spring存储库,意识到快照文件来自今天(11/23/2017).因此,今天有一个新的快照,而该版本中的execSpec也已不存在.由于您的问题来自10月,因此我们可能无法使用相同的文件,但是您可能遇到了相同的问题.我真的不明白为什么execSpec似乎来来去去,但是我想这是使用SNAPSHOT版本的代价.

Then I directly checked the Spring repository and realised that the snapshot files are from today (11/23/2017). So a new snapshot came in today and execSpec is gone in that version. Since your question is from October we are probably not working with the same file but you might have had the same problem. I do not really get why execSpecseems to come and go, but I guess this is the price of using SNAPSHOT-versions.

因此,要等到第一个稳定的版本或下一个再次包含execSpec或提供设置系统变量的可能性的下一个快照时,我们对此问题无能为力.

So there is not much that we can do about the problem than wait until the first stable build or next snaphot that contains execSpec again or offers another possibility of setting system variables.

我在此处询问了Spring-Guys.execSpec发生了什么.所以bootRun回到了JavaExec.因此根本不可能再在其中使用execSpec.

I asked the Spring-guys here what happened to execSpec. So bootRun is back to being a JavaExec. So it is simply not possible anymore to use execSpec there.

这篇关于使用gradle加载命令行属性,但找不到方法execSpec()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆