从Maven项目中的Scala中的其他软件包导入对象

发布于 2025-02-13 02:08:17 字数 320 浏览 0 评论 0 原文

我需要将一个名为javaccparser的对象导入到一个名为frontend的其他软件包中的另一个对象。但找不到。我想我写了正确的道路。

包装中的对象

​在前端包装中,然后解决。 添加denpendency

I need to import an object named JavaCCParser into another object which is in a different package named frontend. But it can not find. I think I write the correct path.

object in a package

import in another package

I add a dependency in pom.xml in frontend package and then solved it.
add denpendency

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

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

发布评论

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

评论(1

套路撩心 2025-02-20 02:08:17

这些看起来不像它们在相同的模块(带蓝色框的文件夹中,包含其自己的 src root)。

从另一个使用 packages 模块将要求您将模块作为另一个 module 作为其他模块 build.sbt

类似于(对于项目范围 build.sbt ):

lazy val root = project
    .in(file("."))
    .aggregate( neoForJAstFactory, frontend, ... )
    ... // Other config stuff

lazy val neoForJAstFactory = project
    .in(file("neo4j-ast-factory"))
    ... // Other config stuff

lazy val frontend = project
    .in(file("frontend"))
    .dependsOn(neoForJAstFactory)
    ... // Other config stuff

一旦将模块作为您希望使用的模块的依赖项,该包应该可用于导入(应该在-范围)。

这是sbt doc:

Those don't look like they are in the same module (folder with a blue box, contains its own src root).

To use packages from another module would require you to import the module as a dependency in the other module in the build.sbt.

Something like (for a project-wide build.sbt):

lazy val root = project
    .in(file("."))
    .aggregate( neoForJAstFactory, frontend, ... )
    ... // Other config stuff

lazy val neoForJAstFactory = project
    .in(file("neo4j-ast-factory"))
    ... // Other config stuff

lazy val frontend = project
    .in(file("frontend"))
    .dependsOn(neoForJAstFactory)
    ... // Other config stuff

Once you add the module as a dependency to the module you wish to use it in, the package should be available for import (it should be in-scope).

Here is the sbt doc: Multi-Project

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