SBT jetty webapp - src 中的文件未复制到目标文件夹中 - 无法查看我放置在那里的简单 HTML 文件
好吧,我是 SBT 和 Scala 的新手,我正在尝试创建一个简单的 Web 应用程序。 现在我正在努力让一些简单的 HTML 文件显示在 http://localhost:8080 上 我的文件夹结构如下:
+clever_dropbox_server
|-+project
| |-+boot
| | |-...
| |-+plugins
| | |-build.sbt
| | |-...
| |-+target
| | |-...
|-+src
| |-+main
| | |-+scala
| | |-+webapps
| | | |-+cleverdropbox
| | | | |-+css
| | | | | |-style.css
| | | | |-+images
| | | | | |-...
| | | | |-+js
| | | | | |-...
| | | | |-+WEB-INF
| | | | | |-+classes
| | | | |-index.html
| | | | |-...
| |-+test
| | |-...
|-+target
| |-...
|-build.sbt
嗯,plugins 下的 build.sbt 文件包含以下内容:
//**********************
//* SBT Eclipse plugin *
//**********************
resolvers += {
val typesafeRepoUrl = new java.net.URL("http://repo.typesafe.com/typesafe/releases")
val pattern = Patterns(false, "[organisation]/[module]/[sbtversion]/[revision]/[type]s/[module](-[classifier])-[revision].[ext]")
Resolver.url("Typesafe Repository", typesafeRepoUrl)(pattern)
}
libraryDependencies <<= (libraryDependencies, sbtVersion) { (deps, version) =>
deps :+ ("com.typesafe.sbteclipse" %% "sbteclipse" % "1.3-RC2" extra("sbtversion" -> version))
}
//******************
//* SBT Web plugin *
//******************
resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"
//Following means libraryDependencies += "com.github.siasia" %% "xsbt-web-plugin" % "0.1.1-<sbt version>""
libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % ("0.1.1-"+v))
这样我就能够在 eclipse 中处理该项目,并获得 Web 插件支持。
主目录中的 build.sbt 文件包含:
name := "clever_dropbox_server"
version := "0.1"
organization := "GilaDana"
scalaVersion := "2.9.0-1"
seq(webSettings: _*)
resolvers += "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"
// Customize any further dependencies as desired
libraryDependencies ++= Seq(
"org.mortbay.jetty" % "jetty" % "6.1.22" % "jetty,test",
"org.eclipse.jetty" % "jetty-server" % "7.4.5.v20110725",// % "compile,jetty",
"org.eclipse.jetty" % "jetty-servlet" % "7.4.5.v20110725",// % "compile,jetty",
"javax.ws.rs" % "jsr311-api" % "1.1.1",
"com.sun.jersey" % "jersey-server" % "1.8",
"com.sun.jersey" % "jersey-core" % "1.8",
"com.sun.jersey" % "jersey-json" % "1.8",
"org.scala-tools.testing" % "specs_2.9.0" % "1.6.8" % "test", // For specs.org tests
"javax.servlet" % "servlet-api" % "2.5" % "provided->default"
)
我的意图是拥有一个简单的 jetty 服务器来服务浏览器请求,以及另一个嵌入式 jetty 服务器在不同的端口上提供 smart_dropbox_client 通信服务。两者都必须处理相同的数据库和相同的文件夹,但除此之外,两者之间没有任何关系。
(关于该项目的几句话:我是 BIU 的一名学生,我们让这个项目创建一个类似保管箱的应用程序,仅进行一些修改,例如仅存储服务器上每个文件的一个副本 - 即使它由 2 个不同的用户以不同的名称共享 - 以节省服务器存储,或者具有与每个帐户中的文件具有 M:N 关系的标记系统,等等'...)
问题是,当我执行 jetty-run 命令时从 sbt 控制台中,我得到404 on localhost:8080/cleverdropbox
当我试图找出原因时,我发现 sbt 不会将 HTML/JS/CSS 文件复制到目标文件夹。
我不想手动复制文件,我也不认为我应该这样做(sbt 会允许吗?或者文件是否会在下一个重新加载/更新/编译命令时被删除?)
那么,我做错了什么?
well, I'm a newbie to both SBT and Scala, and I'm trying to create a simple web app.
right now I'm struggling to get some simple HTML files to show on http://localhost:8080
my folder structure is as follows:
+clever_dropbox_server
|-+project
| |-+boot
| | |-...
| |-+plugins
| | |-build.sbt
| | |-...
| |-+target
| | |-...
|-+src
| |-+main
| | |-+scala
| | |-+webapps
| | | |-+cleverdropbox
| | | | |-+css
| | | | | |-style.css
| | | | |-+images
| | | | | |-...
| | | | |-+js
| | | | | |-...
| | | | |-+WEB-INF
| | | | | |-+classes
| | | | |-index.html
| | | | |-...
| |-+test
| | |-...
|-+target
| |-...
|-build.sbt
well, the build.sbt file under plugins, contain this:
//**********************
//* SBT Eclipse plugin *
//**********************
resolvers += {
val typesafeRepoUrl = new java.net.URL("http://repo.typesafe.com/typesafe/releases")
val pattern = Patterns(false, "[organisation]/[module]/[sbtversion]/[revision]/[type]s/[module](-[classifier])-[revision].[ext]")
Resolver.url("Typesafe Repository", typesafeRepoUrl)(pattern)
}
libraryDependencies <<= (libraryDependencies, sbtVersion) { (deps, version) =>
deps :+ ("com.typesafe.sbteclipse" %% "sbteclipse" % "1.3-RC2" extra("sbtversion" -> version))
}
//******************
//* SBT Web plugin *
//******************
resolvers += "Web plugin repo" at "http://siasia.github.com/maven2"
//Following means libraryDependencies += "com.github.siasia" %% "xsbt-web-plugin" % "0.1.1-<sbt version>""
libraryDependencies <+= sbtVersion(v => "com.github.siasia" %% "xsbt-web-plugin" % ("0.1.1-"+v))
so I'll have the ability to work on the project in eclipse, and for the web plugin support.
the build.sbt file in the main directory contains:
name := "clever_dropbox_server"
version := "0.1"
organization := "GilaDana"
scalaVersion := "2.9.0-1"
seq(webSettings: _*)
resolvers += "Java.net Maven2 Repository" at "http://download.java.net/maven/2/"
// Customize any further dependencies as desired
libraryDependencies ++= Seq(
"org.mortbay.jetty" % "jetty" % "6.1.22" % "jetty,test",
"org.eclipse.jetty" % "jetty-server" % "7.4.5.v20110725",// % "compile,jetty",
"org.eclipse.jetty" % "jetty-servlet" % "7.4.5.v20110725",// % "compile,jetty",
"javax.ws.rs" % "jsr311-api" % "1.1.1",
"com.sun.jersey" % "jersey-server" % "1.8",
"com.sun.jersey" % "jersey-core" % "1.8",
"com.sun.jersey" % "jersey-json" % "1.8",
"org.scala-tools.testing" % "specs_2.9.0" % "1.6.8" % "test", // For specs.org tests
"javax.servlet" % "servlet-api" % "2.5" % "provided->default"
)
my intentions are to have one simple jetty server that will serve for browser requests, and another embedded jetty server to serve on a different port for clever_dropbox_client communication. both would have to deal with the same database, and same files folder, but other than that, there is no relation between the two.
(a few words on the project: I'm a student at BIU, and we got this project to create a dropbox-like application, only with a few modifications, like storing only one copy from each file on the server - even if it is shared by 2 different users under different names - to save server storage, or having a tagging system with M:N relation to the files in each account, etc'...)
the problem is, that when i execute jetty-run command from within the sbt console, i get 404 on localhost:8080/cleverdropbox
when i tried to figure out why, i discovered that sbt won't copy the HTML/JS/CSS files to the target folder.
I wouldn't want to copy the files manually, nor do i think i should (will sbt allow it? or are the files going to be deleted on the next reload/update/compile command?)
so, what am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如评论中所述,
sbt
将在src/main/webapp
文件夹中查找 HTML 文件,不带尾随的 's'。As stated in the comment,
sbt
will look for your HTML files in thesrc/main/webapp
folder, without your trailing 's'.