IntelliJ-Gradle-Kotlin-Micronaut-更改文件不会在“运行"时重新生成类. [英] IntelliJ - Gradle - Kotlin - Micronaut - Changing files does not re-generate classes on "run"
问题描述
我在IntelliJ和Gradle v5.3中有一个Kotlin-Micronaut v.1.0.2项目. 例如,我正在运行的应用程序具有以下控制器:
I have a Kotlin-Micronaut v.1.0.2 project in IntelliJ and with Gradle v5.3. My running application has for example the following controller:
@Controller("/api/test")
class TestController {
@Get
fun helloWorld() = "Hello World"
}
如果我更改了任何代码,例如更改返回值或添加了其他REST方法(例如POST),则仅在./gradlew clean build
上生成必要的代码.在IntelliJ中点击运行"将不会为我生成必要的终结点(例如,添加POST终结点并尝试对其进行卷曲时,在清理构建之前会得到不允许使用方法").
In case I change any of this code, for example change the return value or add another REST method (e.g. POST), the necessary code will only be generated on a ./gradlew clean build
. Hitting "Run" in IntelliJ will not generate the necessary endpoints for me (e.g. on adding a POST endpoint and trying to curl it, I get "Method not allowed" until I clean build).
您有什么建议吗?
推荐答案
启用设置(macOS上的首选项)|构建,执行,部署|生成工具|摇篮|赛跑者| 将IDE构建/运行操作委托给Gradle 选项.这样,IDE将根据您使用的Gradle插件的逻辑使用Gradle生成和构建类.
Enable Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Gradle | Runner | Delegate IDE build/run actions to Gradle option. This way IDE will use Gradle to generate and build classes according to logic of Gradle plugins you are using.
这篇关于IntelliJ-Gradle-Kotlin-Micronaut-更改文件不会在“运行"时重新生成类.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!