如何从项目abc导入类main以供项目web中的另一个类在multi-project sbt配置中使用?
在sbt compile上我得到:
object abc is not a member of package com not 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内部web项目
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() (){有什么不对的?谢谢。
发布于 2015-08-13 09:59:42
结果表明,项目main的目录结构与maven目录结构不同,即在此描述
src/
main/
scala/
com/bla/bla
test/
scala/
<test Scala sourcesIntellij成功地编译了该项目,因为无论旧的目录结构是什么,它在File -> project structure -> modules -> sources下都被标记为File -> project structure -> modules -> sources。
发布于 2020-12-14 09:28:01
有同样的错误,出于同样的原因
我有
lazy val Project_1 =
Project(
id = "project-1",
base = file("./project-1/"),
)
.settings(
sourceDirectory := file("./src/main/scala/"),
)但正确的是
.settings(
sourceDirectory := file("./src/"),
)./src/main/scala/看起来就像
$ tree src/main/scala/
src/main/scala/
└── org.myorganization.myname
└── myproject
├── MySource1.scala
└── MySource1.scalahttps://stackoverflow.com/questions/31983987
复制相似问题