簡體   English   中英

Lein中的ClassNotFound異常(無法編譯)

[英]ClassNotFound Exception in Lein (can't compile)

我正在嘗試:gen-class Servlet這是我的代碼:

(ns test.test 
(:import (java.io PrintWriter) (javax.servlet.http HttpServlet))
(:gen-class :name test.TestServlet :extends javax.servlet.http.HttpServlet))

(defn -doGet[request response]
    (let [wrtr (.getWriter response)]
        (.println wrtr "hello from clojure")))

Lein不能編譯它,它說“主”線程中的異常java.lang.ClassNotFoundException:javax.servlet.http.HttpServlet(Test.clj:1)

我已經將Lein中的:library-path修改為“:library-path” / home / long / workspaces / spring / LongHDi / war / WEB-INF / lib“,但是它沒有用。

你知道為什么嗎?

我正在嘗試使用Google App Engine。 我要擴展的servlet類已經在我指定的lib文件夾中。

您正在使用哪個版本的lein?

我從這里下載了jetty,而lein version1在project.clj中為我工作

(defproject st2 "1.0.0-SNAPSHOT"
 :description "FIXME: write description"
 :library-path "/Users/Niko/Downloads/jetty-hightide-8.1.7.v20120910/lib"
 :aot [st2.core]
 :dependencies [[org.clojure/clojure "1.3.0"]])

st2.core與您的代碼相同:

(ns st2.core
 (:import (java.io PrintWriter) (javax.servlet.http HttpServlet))
 (:gen-class :name test.TestServlet :extends javax.servlet.http.HttpServlet))

(defn -doGet[request response]
  (let [wrtr (.getWriter response)]
    (.println wrtr "hello from clojure")))

如果您使用的是lein2,則不支持:library-path,因此我懷疑您必須添加依賴項“ a-la-maven”並將其添加到項目依賴項中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM