部署使用 IDEA 构建的 scala 应用

发布于 2024-11-27 02:33:25 字数 364 浏览 8 评论 0 原文

我开发了一个简单的 scala 应用程序,它使用 casbah 查询数据库以获取传递给它的命令行参数。例如,

$ querydb.scala execution 10

它将运行 casbah 查询来查找 10 条与 mongo 中执行匹配的记录。现在我有两个问题。

1)我如何在本地测试这个。如果我在 intellij 中单击“执行”,它只是运行该程序,我无法将命令行参数传递给我的程序。

2)我如何部署它以在我的服务器上运行,它只是在我的ubuntu服务器中用作控制台应用程序,但我不确定我应该如何部署它,我应该在服务器上放置哪些文件以及如何做在服务器中执行它,等等。

任何指示都会对我有用。

I developed a simple scala app that uses casbah to query the DB for the command line argument passed to it. For example

$ querydb.scala execution 10

it will run a casbah query to find 10 records matching execution in mongo. Now i have two questions.

1) How do i test this in my local. If i click execute in intellij it is just running the program, i am not able to pass command line arguments to my program.

2) How do i deploy it to run on my server, it is just going to used as console app in my ubuntu server, but im not sure how i should deploy this, which files i should put up on the server and how do i execute it in server, and stuff like that.

Any pointers would be useful for me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

何止钟意 2024-12-04 02:33:25

或者尝试使用 sbt,IDEA 有一个带有 sbt 的插件,它的 wiki 有关于如何使用它的解释。
我通常直接在终端中使用 sbt,而不是在 IDE 中运行。

or try to use sbt, IDEA has a plugin with sbt, the wiki of it has an explanation on how to use it.
I usually use sbt directly in Terminal instead of running in IDE.

鹿! 2024-12-04 02:33:25

1) 首先,您需要在屏幕顶部找到“选择运行/调试配置”按钮

在此处输入图像描述

单击并选择编辑

在此处输入图像描述

创建新的(如果您还没有)。

在此处输入图像描述

您的程序参数应写入“程序参数”字段

在此处输入图像描述

2) 使用 scalac 你会得到 .class 文件。
然后部署它,就像您通常使用 java 所做的那样代码。因此你不需要在目标机器上安装 scala - 你需要的只是 JDK。

1) First you need to find "Select Run/Debug Configuration" button at the top of your screen

enter image description here

Click on it and choose edit

enter image description here

Create new one, if you haven't got it yet.

enter image description here

Your program parameters should be written in "Program parameters" field

enter image description here

2) Compile your .scala files with scalac and you'll got .class files.
Then deploy it, as you usually do with java code. Hence you don't need to install scala on target machine - all you need is JDK.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文