我正在尝试将我的clojure Web应用程序部署在tomcat上,但它只能访问第一条路由。
这是我的专案。clj
(defproject web-app "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.8.0"]
[clj-jgit "0.8.10"]
[org.clojure/data.json "0.2.6"]
[clj-yaml "0.4.0"]
[io.forward/yaml "1.0.9"]
[hiccup "1.0.5"]
[compojure "1.6.1"]
[ring/ring-core "1.6.3"]
[ring/ring-defaults "0.3.2"]
[ring/ring-jetty-adapter "1.6.3"]]
:plugins [[lein-uberwar "0.2.0"]]
;;:plugins [[lein-ring "0.12.4"]]
:uberwar {:handler handler.core/app}
;;:ring {:handler handler.core/app}
:main handler.core)
这是我的服务员
(ns handler.core
(:require [layout.core :as veiw_mapper]
[web-app.core ]
[compojure.core :refer :all]
[compojure.route :as route]
[ring.adapter.jetty :as jetty]
[ring.middleware.defaults :refer [wrap-defaults site-defaults]]
[ring.middleware.resource])
(:gen-class))
(defroutes app-routes
(GET "/" [] (veiw_mapper/index))
(POST "/" [& params] (web-app.core/update-mapper params))
(route/resources "/")
(route/not-found "Not Found"))
(def app
(wrap-routes app-routes site-defaults))
(defn -main
[& [port]]
(let [port (Integer. (or port
(System/getenv "PORT")
5000))]
(jetty/run-jetty #'app {:port port
:join? false})))
这是我在tomcat上的web.xml文件
<?xml version="1.0" encoding="UTF-8"?>
-<web-app version="2.5"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee">
-<listener>
<listener-class>handler.listener</listener-class>
</listener>
-<servlet>
<servlet-name>handler.core/app servlet</servlet-name>
<servlet-class>handler.servlet</servlet-class>
</servlet>
-<servlet-mapping>
<servlet-name>handler.core/app servlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
问题是当我尝试在我的repl服务器上运行此应用程序时,我正在使用它运行码头,但是当我进行战争并将其部署在tomcat服务器上时,仅(GET “ /” [](veiw_mapper / index))正在运行其他路由,例如邮政和资源,也未加载。
我对clojure和tomcat不熟悉,所以不知道该如何处理clojure或web.xml文件。