gpt4 book ai didi

scala 多 sbt 项目 : object is not a member of package, 未找到类型

转载 作者:行者123 更新时间:2023-12-01 00:49:36 24 4
gpt4 key购买 nike

如何导入类 abc来自项目 main由项目中的另一个类使用 webmulti-project sbt配置?

sbt compile我得到:object abc is not a member of package comnot found: type abc
虽然从 IntelliJ 内部编译成功。

build.sbt

lazy val main = project.in(file("main"))
.settings(commonSettings: _*)

lazy val web = project.in(file("web"))
.settings(commonSettings: _*)
.enablePlugins(PlayScala)
.dependsOn(main)

lazy val root = (project in file("."))
.dependsOn(web, main)
.aggregate(web, main)
.settings(commonSettings: _*)


mainClass in root in Compile := (mainClass in web in Compile).value

fullClasspath in web in Runtime ++= (fullClasspath in main in Runtime).value

fullClasspath in root in Runtime ++= (fullClasspath in web in Runtime).value

网络项目 :
package com.company.web.controllers
import _root_.com.company.main.abc // also tried without root.
// Intellij recognizes the import successuflly

class Posts @Inject() (repo : abc) extends Controller { ..

主体工程 :
package com.company.main
class abc @Inject() (){

可能有什么问题?
谢谢。

最佳答案

翻出项目main的目录结构不是根据 maven目录结构,如 described here

src/
main/
scala/
com/bla/bla
test/
scala/
<test Scala sources

Intellij 成功编译了该项目,因为无论旧目录结构到位,它都被标记为 source directoryFile -> project structure -> modules -> sources

关于scala 多 sbt 项目 : object is not a member of package, 未找到类型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31983987/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com