我需要将 python 脚本和库集成到 spring-boot 应用程序中

问题描述

我正在开发一个 spring boot 应用程序,它需要调用一个带有少量参数的 python 脚本并从 python 获取结果。我需要将应用程序开发为可移植的单个单元。我有一个使用 maven jpython/python 集成的想法(为 python 的东西制作 python 的 jar 文件 + 库)。这可能吗?如果是怎么做呢?或者另一种方式来做 maven python 集成?

解决方法

它需要调用一个带有少量参数的python脚本并从python获取结果

不确定您是否真的熟悉 Spring Integration,但既然您提到了该标签,当 Python 语言是您可以使用的其中一种语言时,我将与您分享该项目中的脚本支持这样的集成:https://docs.spring.io/spring-integration/reference/html/messaging-endpoints.html#scripting

这里还有一些支持脚本的示例项目:https://github.com/spring-projects/spring-integration-samples/tree/master/applications/cafe-scripted