我正在尝试使用jpa in play 2.3.6在mysql中创建我的数据库,但是没有创建evolutions脚本。
我的 build.sbt
name := "myapp"
version := "1.0"
lazy val `myapp` = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.11.1"
libraryDependencies ++= Seq(javaJdbc ,
javaJpa.exclude("org.hibernate.javax.persistence", "hibernate-jpa-2.0-api"),
cache ,
"mysql" % "mysql-connector-java" % "5.1.18",
"org.hibernate" % "hibernate-entitymanager" % "4.3.9.Final" )
unmanagedResourceDirectories in Test <+= baseDirectory ( _ /"target/web/public/test" )
application.conf
# This is the main configuration file for the application.
# ~~~~~
# Secret key
# ~~~~~
# The secret key is used to secure cryptographics functions.
# If you deploy your application to several instances be sure to use the same key!
application.secret="%APPLICATION_SECRET%"
# 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 `my.application.Router`,
# you may need to define a router file `conf/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:3306/db"
db.default.user="user"
db.default.password="pass"
db.default.jndiName=DefaultDS
jpa.default=defaultPersistenceUnit
# Evolutions
# ~~~~~
# You can disable evolutions if needed
# evolutionplugin=disabled
# 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
我的模特
@Entity
public class Account {
@Id
@Column(name = "id", nullable = false)
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
@Constraints.Required
private String name;
}
CONF / META-INF / persistence.xml中
<?xml version="1.0" encoding="UTF-8"?>
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
version="2.1">
<persistence-unit name="defaultPersistenceUnit" transaction-type="RESOURCE_LOCAL">
<provider>org.hibernate.jpa.HibernatePersistenceProvider</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
</properties>
</persistence-unit>
</persistence>
当我运行项目时,它会像我给出的那样加载索引页面,但它不会要求应用此脚本部分,也不会生成生成名称中的脚本1.sql
我似乎无法跟踪问题,我发现了一个类似的问题,但在那个线程上解决方案再次创建项目我也尝试了但是这样做不起作用,我也找不到任何问题解决这个问题。
我似乎无法解决问题所在,因为没有控制台错误,我从头开始重新检查了所有内容但同样的问题。
如果有人能指出我正确的方向,那将是一个很大的帮助。
由于