小编use*_*078的帖子

DDD,JPA和Multi-Module Maven

我正在尝试使用Spring/JPA配置和Maven多模块项目.这是总体布局.我有一个带有5个子模块的根模块.

backoffice (root maven module)
|
-(maven module)-----core (this is where persistence.xml and entityManager stuff resides).
|
-(maven module)-----employee (employee related entities, controllers, etc.)
|
-(maven module)-----vendor (vendor related entities, controllers, etc.)
|
-(maven module)-----customer (customer related entities, controllers, etc.)
|
-(maven module)-----web (contains all the web stuff).

我在core/src/main/resources/META-INF(persistence.xml,spring-context w/EntityManagerFactory,dataSource等)中拥有所有jpa内容.我的想法是希望在所有子模块(员工,供应商和客户)之间共享持久性内容.

问题是,当Web应用程序启动时,它找不到EntityMangerFactory.如果我在每个子模块(员工,供应商和客户)中设置JPA东西,那么它可以工作.

如何在核心中设置所有与持久性相关的东西,然后在其他模块中共享它?

提前致谢.

java spring domain-driven-design jpa maven

14
推荐指数
1
解决办法
4383
查看次数

匹配Java接口时的Scala匹配/ case语句

我正在使用Scala match/case语句来匹配给定java类的接口.我希望能够检查一个类是否实现了接口的组合.我似乎能够使这个工作的唯一方法是使用match/case看似丑陋的嵌套语句.

假设我有一个实现Person,Manager和Investor的PersonImpl对象.我想看看PersonImpl是否实现了Manager和Investor.我应该能够做到以下几点:

person match {
  case person: (Manager, Investor) =>
    // do something, the person is both a manager and an investor
  case person: Manager =>
    // do something, the person is only a manager
  case person: Investor =>
    // do something, the person is only an investor
  case _ =>
    // person is neither, error out.
}
Run Code Online (Sandbox Code Playgroud)

case person: (Manager, Investor)是行不通的.为了使它工作,我必须做以下似乎很难看.

person match {
  case person: Manager = {
    person match {
      case …
Run Code Online (Sandbox Code Playgroud)

scala pattern-matching

3
推荐指数
1
解决办法
2972
查看次数