gpt4 book ai didi

java - 部署多模块Play项目

转载 作者:太空宇宙 更新时间:2023-11-04 10:58:12 25 4
gpt4 key购买 nike

我正在尝试使用 SBT 部署多模块 Play 项目。我们的项目有5个模块[commons, channel , ...] 。当我使用sbt run时在我的本地系统中,一切正常。为了在服务器中部署,我使用 sbt distbuild the project 。但是当我使用 sbt dist 生成的脚本运行我的应用程序时,问题就出现了!

这是一个错误示例:

[error] error_handler - Unhandled Error
java.lang.IllegalArgumentException: No query defined for that name [automaticChannel.getTagByChannelId]
at org.hibernate.internal.AbstractSharedSessionContract.buildQueryFromName(AbstractSharedSessionContract.java:770)
at org.hibernate.internal.AbstractSharedSessionContract.createNamedQuery(AbstractSharedSessionContract.java:748)
at org.hibernate.internal.AbstractSessionImpl.createNamedQuery(AbstractSessionImpl.java:23)
at repositories.GenericRepository.namedQuery(GenericRepository.java:291)
at repositories.GenericRepository.namedNativeQuery(GenericRepository.java:573)
at repositories.AutomaticChannelRepository.getTagIds(AutomaticChannelRepository.java:63)
at services.AutomaticChannelService.lambda$tagIds$6(AutomaticChannelService.java:159)
at play.db.jpa.DefaultJPAApi.lambda$withTransaction$3(DefaultJPAApi.java:197)
at play.db.jpa.DefaultJPAApi.withTransaction(DefaultJPAApi.java:138)
at play.db.jpa.DefaultJPAApi.withTransaction(DefaultJPAApi.java:196)

GenericRepository类存在于commons模块中,AutomaticChannelRepository存在于channel模块中。

buid.sbt 的一部分文件:

lazy val connector = (project in file("modules/connector"))
.enablePlugins(PlayScala)
.settings(
commonSettings,
libraryDependencies += "org.mindrot" % "jbcrypt" % "0.4"
)

lazy val common = (project in file("modules/common"))
.enablePlugins(PlayJava)
.dependsOn(connector)
.settings(
commonSettings,
libraryDependencies ++= Seq(
javaJdbc,
filters,
guice,
javaWs,
ehcache,
javaJpa,
evolutions,
"org.hibernate" % "hibernate-entitymanager" % "5.2.11.Final",
"org.hibernate" % "hibernate-ehcache" % "5.2.11.Final",
"org.hibernate.javax.persistence" % "hibernate-jpa-2.1-api" % "1.0.0.Final",
"com.google.code.gson" % "gson" % "2.1",
"com.oracle" % "ojdbc8" % "12.2.0.1",
"commons-io" % "commons-io" % "2.4",
"commons-lang" % "commons-lang" % "2.6",
"org.apache.commons" % "commons-collections4" % "4.1",
"org.hibernate" % "hibernate-core" % "5.2.10.Final",
"org.apache.tika" % "tika-core" % "1.13",
"org.apache.tika" % "tika-parsers" % "1.13" exclude("com.google.code.gson", "gson"),
"org.apache.tika" % "tika-xmp" % "1.13",
"org.jsoup" % "jsoup" % "1.10.1",
"com.thoughtworks.xstream" % "xstream" % "1.3"
)
)

lazy val search = (project in file("modules/search")).enablePlugins(PlayJava).dependsOn(common).settings(commonSettings)
lazy val channel = (project in file("modules/channel")).enablePlugins(PlayJava).dependsOn(common, search).settings(commonSettings)
lazy val recommend = (project in file("modules/recommend")).enablePlugins(PlayJava).dependsOn(common, search).settings(commonSettings)

lazy val root = (project in file("."))
.enablePlugins(PlayJava)
.dependsOn(channel, recommend)
.aggregate(channel, recommend)
.settings(commonSettings)

我想知道 sbt run 和有什么区别和sbt dist

部署多模块 SBT 项目的常见和推荐方法是什么?

最佳答案

这是一个类路径问题。您必须将以下代码放入 build.sbt 中:

PlayKeys.externalizeResources := false

默认情况下,项目中的资源不会打包在 sbt dist 创建的 jar 文件中。

关于java - 部署多模块Play项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47159335/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com