在没有 main 方法的 Eclipse 中执行 Scala 对象
我的任务是在 Scala 中编写几个方法。这些方法将被封装在一个没有 main 方法的对象中。教授给了我们一个 JAR 文件,其中包含一个接口(我的对象实现了这个接口)以及一种对我的每个函数执行各种断言语句的伪测试对象。该对象也不包含 main 方法。
现在在 Intellij 中,我只需在类路径中声明对 JAR 的依赖关系,它就可以正常运行。 Eclipse 给我带来了麻烦,因为当我去定义 Scala 应用程序运行配置时,它特别要求我命名包含 main 方法的类,但没有 main 方法。
我假设我可能为这种类型的设置选择了错误的项目类型,但我对此缺乏经验,并且我将不胜感激您对于在 Eclipse 中运行此类内容的任何建议。
谢谢。
I have an assignment to code several methods in Scala. The methods will be encapsulated in an object that has no main method. The professor gave us a JAR file that contains an interface (my object implements this interface) as well as a sort of pseudo test object that performs various assert statements against each of my functions. This object also does not contain a main method.
Now in Intellij I simply had to declare the dependency on the JAR in the classpath, and it runs fine. Eclipse is giving me trouble though because when I go to define a Scala application run configuration it specifically asks me to name the class that contains a main method, and there is no main method.
I am assuming that I might be choosing the wrong project type for this type of set up, but I am inexperienced with this and I would appreciate any advice you might have for running something like this in eclipse.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我会:
只编写一个带有调用测试对象的 main 方法的对象,或者
在你的应用程序中启动一个 Scala 解释器项目(从上下文菜单中,Scala 下)。
首选第一种方法,因为修改后重复测试速度更快。
I would either:
just write an object with a main method which calls the test object, or
start a Scala interpreter in your project (from context menu, under Scala).
Preferring the first approach, because it's faster to repeat tests after a modification.