简体   繁体   English

IntelliJ 项目“JS 客户端和 JVM 服务器 | Gradle”不起作用

[英]IntelliJ Project "JS Client and JVM Server | Gradle" does not work

when I create the stated project type with Intellij Ultimate 2019.2当我使用 Intellij Ultimate 2019.2 创建指定的项目类型时

and then build the project (F11)然后构建项目(F11)

following error appears:出现以下错误:

构建错误

However when I run the SampleJvm.kt:但是,当我运行 SampleJvm.kt 时:跑

Netty start and everything seems fine. Netty 开始,一切似乎都很好。 Unfortunately the code is not working correctly:不幸的是,代码无法正常工作:

仍然是错误

The issue seems to be that the backend cannot find the compiled testy.js, which shall be loaded as a resource and then added to the HTML site:问题好像是后端找不到编译好的testy.js,应该作为资源加载然后添加到HTML站点:

问题

I uploaded the project for download: https://file.io/Jj50Ow我上传了项目下载: https : //file.io/Jj50Ow

Thank you so much for any advice, Best Chris非常感谢您的任何建议,最好的克里斯

The js file is generated and packaged in a jar file, but the JVM server does not have a dependency on that JAR file and therefore it generates 404. js文件生成并打包成jar文件,但JVM服务器不依赖该JAR文件,因此生成404。

Open the build.gradle file and scroll to the bottom, add jsJar to the dependsOn and the classpath:打开 build.gradle 文件并滚动到底部,将 jsJar 添加到dependsOn 和类路径:

task run(type: JavaExec, dependsOn: [jvmJar, jsJar]) {
    group = "application"
    main = "sample.SampleJvmKt"
    classpath(configurations.jvmRuntimeClasspath, jvmJar, jsJar)
    args = []
}

And then you can run the app with gradle.然后你可以用 gradle 运行应用程序。

At this time, the new project generator doesn't correctly handle multiplatform projects.此时,新的项目生成器无法正确处理多平台项目。

There is a working example with Ktor on the back-end and React on the front-end, including hot-reload for UI development: https://github.com/Kotlin/kotlin-full-stack-application-demo有一个在后端使用 Ktor 而在前端使用 React 的工作示例,包括用于 UI 开发的热重载: https : //github.com/Kotlin/kotlin-full-stack-application-demo

I was able to get it working with Kotlin Gradle DSL, with a Spring Boot back-end (including being able to debug from IDE) and hot-reload of React front-end: https://github.com/alexoooo/sample-multiplatform-boot-react我能够使用 Kotlin Gradle DSL、Spring Boot 后端(包括能够从 IDE 进行调试)和 React 前端的热重载: https : //github.com/alexoooo/sample-多平台引导反应

Note that Kotlin multiplatform projects are currently experimental, and some of the details are likely to change as the new IR is introduced: https://blog.jetbrains.com/kotlin/2020/03/kotlin-1-4-m1-released/请注意,Kotlin 多平台项目目前处于实验阶段,随着新 IR 的引入,一些细节可能会发生变化: https : //blog.jetbrains.com/kotlin/2020/03/kotlin-1-4-m1-released /

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM