我使用play 2.3.6和JPA ORM来处理数据,所以我按照playframework(https://www.playframework.com/documentation/2.3.x/JavaJPA)的文档进行操作,但我不知道为什么包play.db.jpa没有导入进入我的项目。
我尝试清理我的项目(激活干净,激活干净文件)但没有改变
错过了什么工作?
下面是我的配置:
build.sbt
name := "play_sample1"
version := "1.0"
libraryDependencies ++= Seq(
javaJdbc,
cache,
javaWs,
javaJpa,
"org.hibernate" % "hibernate-entitymanager" % "4.3.6.Final",
"mysql" % "mysql-connector-java" % "5.1.18"
)
lazy val root = (project in file(".")).enablePlugins(PlayJava)
.aggregate(common, webstats)
.dependsOn(common, webstats)
lazy val core = (project in file("modules/core")).enablePlugins(PlayJava)
lazy val common = (project in file("modules/common")).enablePlugins(PlayJava).dependsOn(core)
lazy val webstats = (project in file("modules/webstats")).enablePlugins(PlayJava).dependsOn(common)
appplication.conf
# This is the main configuration file for the application.
# ~~~~~
# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
#
# This must be changed for production, but we recommend not changing it in this file.
#
# See http://www.playframework.com/documentation/latest/ApplicationSecret for more details.
application.secret="yIX1uonulRO^O8A56tlkb1c4aJS^@9k<dr@^mDXuSBXggKHMRJykv@>``Ra?yh<i"
# The application languages
# ~~~~~
application.langs="en"
# Global object class
# ~~~~~
# Define the Global object class for this application.
# Default to Global in the root package.
# application.global=Global
# Router
# ~~~~~
# Define the Router object to use for this application.
# This router will be looked up first when the application is starting up,
# so make sure this is the entry point.
# Furthermore, it's assumed your route file is named properly.
# So for an application router like `conf/my.application.Router`,
# you may need to define a router file `my.application.routes`.
# Default to Routes in the root package (and `conf/routes`)
# application.router=my.application.Routes
# Database configuration
# ~~~~~
# You can declare as many datasources as you want.
# By convention, the default datasource is named `default`
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/play_test"
db.default.user=root
db.default.password=""
jpa.default=defaultPersistenceUnit
db.default.jndiName=DefaultDS
# You can expose this datasource via JNDI if needed (Useful for JPA)
# db.default.jndiName=play_test
# Evolutions
# ~~~~~
# You can disable evolutions if needed
# evolutionplugin=disabled
# Ebean configuration
# ~~~~~
# You can declare as many Ebean servers as you want.
# By convention, the default server is named `default`
#
# ebean.default="models.*"
# Logger
# ~~~~~
# You can also configure logback (http://logback.qos.ch/),
# by providing an application-logger.xml file in the conf directory.
# Root logger:
logger.root=ERROR
# Logger used by the framework:
logger.play=INFO
# Logger provided to your application:
logger.application=DEBUG
/conf/META-INF/persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
version="2.0">
<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.ejb.HibernatePersistence</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect" />
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.show_sql" value="true"></property>
<property name="hibernate.format_sql" value="true"></property>
</properties>
</persistence-unit>
</persistence>
答案 0 :(得分:0)
尝试删除 javaJdbc 依赖项。
希望它有所帮助!