I work with play 2.3.6 and JPA ORM to the data, so i follow the documentation of playframework (https://www.playframework.com/documentation/2.3.x/JavaJPA) but i don't know why the package play.db.jpa is not imported into my project.
I try to clean my project (activator clean, activator clean-files) but nothing changed
What it miss to work fine ???
below is my configuration :
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>
JPA.em()
in core and common you need to add that as a dependency in core/build.sbt (as common depends on core it is not needed there). The same should apply to the xml files... – SalemjavaJpa
afterjavaJdbc
thenactivator clean
then try to import – singhakash