简体   繁体   English

在java项目中添加node js项目作为依赖

[英]Add node js project as a dependency in a java project

I need to be able to add an existing Node js project as a maven dependency in a java project to be able to call functions from the node js project.我需要能够将现有的 Node js 项目添加为 java 项目中的 maven 依赖项,以便能够从 node js 项目中调用函数。 I researched quiet a bit but am unable to find a way to do this.我安静地研究了一下,但无法找到一种方法来做到这一点。 I do not want to embed js in java, rather just import the libraries.我不想在 java 中嵌入 js,而只是导入库。 Can anybody suggest a way ?任何人都可以提出一种方法吗?

You could create a new Kotlin mutlti-platform project which takes a dependency on your node-js package.您可以创建一个新的 Kotlin 多平台项目,该项目依赖于您的 node-js 包。 Then you could create a wrapper kotlin function which calls your node-js function.然后你可以创建一个包装器 kotlin 函数来调用你的 node-js 函数。 You can then use this Kotlin package as a dependency in your Java package.然后,您可以将此 Kotlin 包用作 Java 包中的依赖项。 Here is more information regarding Kotlin multi-platform: https://kotlinlang.org/docs/multiplatform-library.html以下是有关 Kotlin 多平台的更多信息: https : //kotlinlang.org/docs/multiplatform-library.html

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

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