我想组合 Java/Scala sbt 子项目,使每个模块都是一个独立的 SPA 微服务。由于历史原因,我受限于 Spring Boot (Tomcat) 来提供文件。我选择 Scala.js 来编写 Javascript 客户端。打包是在 sbt 插件的帮助下完成的。相关部分build.sbt
是:
ThisBuild / scalaVersion := "2.12.6"
lazy val iamProject = ProjectRef(uri("https://github.com/iservport/iservport-iam.git"), "iam")
lazy val appCargo = (project in file("app-cargo")).enablePlugins(ScalaJSPlugin, ScalaJSWeb)
lazy val root = (project in file("."))
.enablePlugins(JavaServerAppPackaging, UniversalDeployPlugin, AshScriptPlugin)
.enablePlugins(DockerPlugin, SbtWeb)
.settings(
scalaJSProjects := Seq(appCargo),
pipelineStages in Assets := Seq(scalaJSPipeline),
name := "iservport-control",
mainClass in Compile := Some("com.iservport.Application"),
...
).dependsOn(iamProject, appCargo)
当我展开生成的应用程序 zip 时universal:packageBin
,在 lib 目录下,我可以找到com.iservport.iservport-cargo-1.1.1.RELEASE.jar
(模块),并且:
jar -tf com.iservport.iservport-control-1.1.1.RELEASE.jar | grep cargo
…
META-INF/resources/webjars/iservport-control/1.1.1.RELEASE/14848cb02339ea90f0c6/com/iservport/cargo/service/ShipmentService.scala
META-INF/resources/webjars/iservport-control/1.1.1.RELEASE/iservport-cargo-opt.js.map
META-INF/resources/webjars/iservport-control/1.1.1.RELEASE/14848cb02339ea90f0c6/com/iservport/cargo/service/ShipmentDocumentService.scala
META-INF/resources/webjars/iservport-control/1.1.1.RELEASE/iservport-cargo-opt.js
META-INF/resources/webjars/iservport-control/1.1.1.RELEASE/14848cb02339ea90f0c6/com/iservport/cargo/repository/ShipmentTypeRepository.scala
…
我测试了 Spring Boot 服务 webjars 的能力,例如 d3.js,我看到它工作正常。但是,对于我的 jar 中的类似资源,我看不到相同的 webjar 映射工作:
META-INF/resources/webjars/iservport-control/1.1.1.RELEASE/iservport-cargo-opt.js
我尝试过localhost:8443/webjars/iservport-control/1.1.1.RELEASE/iservport-cargo-opt.js
和localhost:8443/webjars/iservport-control /iservport-cargo-opt.js
其他变体,它们都是 404。
如何将上述内容公开iservport-cargo-opt.js
给客户?