我正在尝试在tomcat上部署我的应用程序。我要访问我的index.html,但我的API会回复
404未找到
我无法弄清楚我做错了什么
这是我的服务演员
class DemoRoute extends Actor with DemoRouteService {
implicit def actorRefFactory: ActorContext = context
def receive = runRoute(route)
}
trait DemoRouteService extends HttpService{
val route = {
import com.tr.em.domain.JsonImplicits._
path("foo"/"status"){
get{
complete("I feel good, thanks for checking")
}
}
}
}
这是我的web.xml
<?xml version="1.0"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0">
<listener>
<listener-class>spray.servlet.Initializer</listener-class>
</listener>
<servlet>
<servlet-name>SprayConnectorServlet</servlet-name>
<servlet-class>spray.servlet.Servlet30ConnectorServlet</servlet-class>
<async-supported>true</async-supported>
</servlet>
<servlet-mapping>
<servlet-name>SprayConnectorServlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
这是我的application.conf
akka {
loglevel = INFO
event-handlers = ["akka.event.slf4j.Slf4jEventHandler"]
}
spray.servlet {
boot-class = "com.tr.em.SprayBoot"
request-timeout = 10s
}
这是我的启动课
import spray.servlet.WebBoot
import akka.actor.ActorSystem
import akka.actor.Props
class SprayBoot extends WebBoot {
val system = ActorSystem("systemactor")
val serviceActor = system.actorOf(Props[DemoRoute])
system.registerOnTermination {
system.log.info("Application shut down")
}
}
答案 0 :(得分:1)
来自spray-servlet文档
#该类必须具有单个构造函数 #
javax.servlet.ServletContext
参数和实现 #spray.servlet.WebBoot
特质。boot-class =“”
看起来你的班级没有合适的构造函数
答案 1 :(得分:0)
解决。这是一种竞争条件。 必须添加日志才能看到真正的错误。无论如何我必须添加将服务actor定义为lazy
lazy val serviceActor = system.actorOf(Props[DemoRoute])