문제

I have a project including three modules.

  • main
  • domain
  • infrastructure

In domain module I have a entity class and a repository trait.

Entity.scala EntityRepository

In infrastructure module I want to extend and implement the EntityRepository trait.

EntityRepositoryImpl extends EntityRepository {...}

But I don't know how to access the trait in the domain mobdule from the infrastructure module.

I'm not sure that I know what I'm doing but here by build.sbt. Tell me if I've done something wrong there.

import play.Project._

lazy val domain = Project("domain", file("domain"))

lazy val infra = Project("infrastructure", file("infrastructure")).dependsOn(domain)

lazy val root = Project("MainModuleName", file(".")).dependsOn(domain, infra)

name := "AppName"

version := "1.0"

playScalaSettings

Now suddenly I can find the EntityRepository in the EntityRepositoryImpl but when I choose to extend it it's still red and showing a 'Cannot resolve...'-error.

Finds the trait

Still red if I choose it

Happy for any kind of feedback! Thanks

올바른 솔루션이 없습니다

다른 팁

Your project setup allows you to access EntityRepository trait which is in domain subproject from anywhere in infra subproject because infra depends on domain. All you need to do is to reference EntityRepository by its full name or import the package where it resides (import com.example.EntityRepository).

If you use IntelliJ you can generate projects for it from sbt using sbt-idea plugin. The same goes for Eclipse with sbteclipse-plugin. This way your generated IDE projects would have proper references to each other and will help you find your classes.

Although you have the same package in two different SBT subprojects it's not a problem. This should not cause any compilation problems.

To eliminate problems that could be caused by IDE a good test is to compile with SBT. Shutdown running sbt, start it over again and run ;clean; compile; test in SBT console. If everything compiles fine (or even if it does not) regenerate your IntelliJ projects with gen-idea from SBT console. For all SBT commands in your case you should be in root project which I suppose is default location when you start SBT.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top