我尝试了一个简单的喷雾示例应用程序,但无法访问路线,我将示例源代码上传到了 github,但该示例源代码不起作用:喷雾 Tomcat 示例 https://github.com/avidanyum/spray-tomcat-example:
git clone https://github.com/avidanyum/spray-tomcat-example
mvn package
cp cp target/spray-tomcat-example-0.1-SNAPSHOT.war ~/tmp/tomcat/apache-tomcat-7.0.61/webapps/spraytomcat.war
cd ~/tmp/tomcat/apache-tomcat-7.0.61/bin
./catalina.sh jpda run
http://localhost:8080/spraytomcat/
I get
"The requested resource could not be found."
我将路线定义如下:
class ServiceActor extends Actor with Service {
def actorRefFactory = context
def receive = runRoute(myRoute)
}
trait Service extends HttpService {
import com.example.domain.Person
val myRoute =
path("") {
get {
respondWithMediaType(`text/html`) {
complete {
<html>
<body>
<h1>Say hello to <i>spray-routing</i> on <i>tomcat</i>!</h1>
</body>
</html>
}
}
}
}
}
当然我有boot
上课到位
in application.conf
spray.servlet {
boot-class = "com.example.SprayBoot"
request-timeout = 10s
}
and SprayBoot
itself:
class SprayBoot extends WebBoot {
val system = ActorSystem("actorsystem")
val serviceActor = system.actorOf(Props[ServiceActor])
}
我很确定我遵循了所有要求,我是否遗漏了什么?我如何更新它以实际提供内容而不是“找不到所请求的资源。”
当您将应用程序部署到 ROOT 上下文中而无需任何额外配置时,该示例将起作用。
我对你的脚本做了一些修改:
git clone https://github.com/avidanyum/spray-tomcat-example
mvn package
cp target/spray-tomcat-example-0.1-SNAPSHOT.war ~/tmp/tomcat/apache-tomcat-7.0.61/webapps/ROOT.war
cd ~/tmp/tomcat/apache-tomcat-7.0.61/bin
./catalina.sh jpda run
wget http://localhost:8080/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)