1

我将persistence.xml文件放入history/src/main/resources/META-INF/但仍然出现错误。

我应该把 XML 文件放在哪里,我应该用 SBT 改变什么?

SBT:

lazy val history = (project in file("history"))
  .settings(
    libraryDependencies += "com.impetus.kundera.client" % "kundera-cassandra" % "2.17"
  )

一些 Scala 代码:(Java 转换很简单)

object Test {
  def main(args: Array[String]) {

    new HistoryCore()

  }
}

class HistoryCore {

  val emf: EntityManagerFactory = Persistence.createEntityManagerFactory("cassandra_pu")

  val em: EntityManager = emf.createEntityManager()
  em.persist(TradeData(DateTime.now(), 1.618))
  em.close()
  emf.close()

  // @BeanProperty dynamically adds a getter and a setter for the given variable. This keeps the code clean and the JPA implementation working
  @Entity
  @Table(name = "users", schema = "KunderaExamples@cassandra_pu")
  case class TradeData(@Id
                       @BeanProperty
                       var time: DateTime,
                       @Column(name = "price")
                       @BeanProperty
                       var price: Double)
}

错误:

20:45:47.537 [main] INFO  c.i.k.p.EntityManagerFactoryImpl - Loading Core
20:45:47.770 [main] INFO  c.impetus.kundera.loader.CoreLoader - Loading Kundera Core Metdata ... 
20:45:47.775 [main] INFO  c.i.k.p.EntityManagerFactoryImpl - Loading Persistence Unit MetaData For Persistence Unit(s) cassandra_pu.
20:45:47.789 [main] INFO  c.i.k.c.PersistenceUnitConfiguration - Loading Metadata from persistence.xml ...
20:45:47.794 [main] ERROR c.i.k.c.PersistenceUnitConfiguration - Could not find any META-INF/persistence.xml file in the classpath

项目结构:

在此处输入图像描述

4

0 回答 0