如何abc从项目中导入类main以供配置中项目web中的另一个类使用multi-project sbt?
当sbt compile我得到:
object abc is not a member of package com
not found: type abc
虽然从 IntelliJ 内部编译成功。
生成.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
Run Code Online (Sandbox Code Playgroud)
内部网络项目:
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 { ..
Run Code Online (Sandbox Code Playgroud)
内部主要项目:
package com.company.main
class abc @Inject() (){
Run Code Online (Sandbox Code Playgroud)
可能有什么问题?谢谢。
原来项目的目录结构main不符合maven目录结构,如此处所述
src/
main/
scala/
com/bla/bla
test/
scala/
<test Scala sources
Run Code Online (Sandbox Code Playgroud)
Intellij 成功编译了该项目,因为无论旧的目录结构是什么,它都被标记source directory为File -> project structure -> modules -> sources