我将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
项目结构: