繁体   English   中英

通过 shell 脚本运行 maven 项目和 python 文件

[英]Running a maven project and a python file through shell script

我正在研究一个 maven 项目,该项目的源文件位于 JAVA 中。 我不得不通过一些已经编写好的代码在项目中添加一些功能。 但是这些新文件是用 PYTHON 编写的。 因此,我决定制作一个 shell 脚本,该脚本可以运行 java 和 python 文件并带有所需的参数。 But since my java source files are in the maven project, I am not able to write a shell script without exploiting the structure of the maven project. 那么,如何在不破坏 maven 项目结构的情况下运行上述文件?

正如安徒生所说,Maven 可以编译和执行.java 文件,这意味着它仅特定于 java。 对于 python 文件,您需要 setup.py 来构建基于 python 的项目。 您不能直接从 Java ZA2F2ED4F8EBC2CBBDZC2A 调用用 Python 编写的 function。 现在回到您的要求,我认为您必须使用命令mvn clean install使用 Maven 单独构建 java 项目,如果 Z23EEEB4347BDD265DDZZB7 项目中可用,则必须运行setup.py Since you cannot call a python function from java class, you have to create an exe file in python using pyinstaller or using py2exe and you invoke the exe file from java. 以上我在其中一种方法中提到。 另一种方法是重写 java 中的 python 代码并使用 maven 构建。 这将是基于需求的好方法。 此外,如果您有兴趣使用 Maven 构建 java 项目并且您想构建 python 项目,您可以编写一个 .bat 文件。

暂无
暂无

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

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