播放框架2.8和postgreSQL 12.5



你好,亲爱的社区和技术的喜悦,我用postgresql12.5创建了一个新的Play框架2.8项目。

postgreSql中没有auto_increment。这里只有(smal,big(系列PostgreSQL-自动增量。

但是,Play尝试使用auto_increment创建一个表。这并不顺利是合乎逻辑的。

create table project_type (
id bigint auto_increment not null,
name varchar (255),
constraint pk_project_type primary key (id)
);
psql -V
psql (PostgreSQL) 12.5 (Ubuntu 12.5-0ubuntu0.20.04.1)
play version: addSbtPlugin ("com.typesafe.play"% "sbt-plugin"% "2.8.5")

我的配置出了什么问题?

application.conf

play {
modules {
enabled += "play.api.db.DBModule"
enabled += "play.api.db.HikariCPModule"
}
ebean.default = ["models.*"]
crypto.secret = "aKr4Mfn!vKzDjfhfdJRsakgbPS35!!HVDldkosGHRT"
}
applyEvolutions.default=true
db.default{
driver = org.postgresql.Driver
url= "jdbc:postgresql://localhost:5432/meineSeite"
username = "andi1"
password = "andi1"
}
# Root logger:
logger=ERROR
# Logger used by the framework:
logger.play=INFO
# Logger provided to your application:
logger.application=DEBUG

build.sbt

name := """meineSeite"""
organization := "com.af86"
version := "1.0-SNAPSHOT"
lazy val root = (project in file("."))
.enablePlugins(PlayJava, PlayEbean)
.settings(
name := "play-java-ebean-example",
version := "1.0.0-SNAPSHOT",
scalaVersion := "2.13.1",
libraryDependencies ++= Seq(
guice,
jdbc,
javaJdbc,
"mysql" % "mysql-connector-java" % "5.1.41",
"org.postgresql"     % "postgresql"   % "9.3-1102-jdbc41",
"org.postgresql" % "postgresql" % "42.2.12",
"javax.xml.bind"     % "jaxb-api"     % "2.3.1",
"javax.activation"   % "activation"   % "1.1.1",
"org.glassfish.jaxb" % "jaxb-runtime" % "2.3.2"
)
)
scalaVersion := "2.13.3"

插件.sbt

// The Play plugin
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.5")
// Defines scaffolding (found under .g8 folder)
// http://www.foundweekends.org/giter8/scaffolding.html
// sbt "g8Scaffold form"
addSbtPlugin("org.foundweekends.giter8" % "sbt-giter8-scaffold" % "0.11.0")
addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.5")
addSbtPlugin("com.typesafe.sbt" % "sbt-play-ebean" % "5.0.2")

现在可以工作了;-(

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.jpa.HibernatePersistenceProvider</provider>
<non-jta-data-source>DefaultDS</non-jta-data-source>
<properties>
<property name="hibernate.dialect" value="org.hibernate.dialect.PostgreSQLDialect"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.show_sql" value="true"/> <!-- show sql in consol -->
</properties>
</persistence-unit>ac
</persistence>

的应用程序

evolutions.enabled="false"

build.sbt

name := """meineSeite"""
organization := "com.af86"
version := "1.0-SNAPSHOT"
lazy val root = (project in file("."))
.enablePlugins(PlayJava, PlayEbean)
.settings(
name := "play-java-ebean-example",
version := "1.0.0-SNAPSHOT",
scalaVersion := "2.13.3",
libraryDependencies ++= Seq(
guice,
jdbc,
javaJdbc,
javaJpa,
"org.hibernate" % "hibernate-core" % "5.4.9.Final",
"org.postgresql" % "postgresql" % "9.4.1212",
"javax.xml.bind"     % "jaxb-api"     % "2.3.1",
"javax.activation"   % "activation"   % "1.1.1",
"org.glassfish.jaxb" % "jaxb-runtime" % "2.3.2"
)
)
scalaVersion := "2.13.3"
PlayKeys.externalizeResourcesExcludes += baseDirectory.value / "conf" / "META-INF" / "persistence.xml"

相关内容

  • 没有找到相关文章

最新更新