IntelliJ 中的 Clojure Web 应用程序梅文 +雄猫
我正在 IntelliJ 中使用 Maven 作为依赖管理器,使用基于 Compojure 的 Clojure Web 应用程序。它基于我在 git 存储库中找到的应用程序“http://assenkolov.blogspot.com/2011/11/sample-clojurecompojure-web-application.html”rel =“nofollow noreferrer”>此示例。当我尝试使用 IntelliJ 的 Tomcat6 配置运行应用程序时,每次都会失败并引用 Servlet 异常:
javax.servlet.ServletException: Wrapper cannot find servlet class tracker.core or a class it depends on
另外查看 web.xml,IntelliJ 无法识别 servlet 类(tracker.core 突出显示)。 >
一点背景知识:
该应用程序最初是作为客户的概念验证而构建的,由我最近离开公司的同事编写。除了过去两天的这个项目工作之外,我个人对 clojure 没有什么经验。使用 Leiningen 环服务器,我可以成功地让应用程序在码头上运行。使用leiningen Ring uberwar,生成的war成功部署并在tomcat中运行。
原始文件结构如下所示:
/tracker-webapp
/classes
/lib
/resources
/src
/tracker
/core.clj (and other *.clj files)
/test
project.clj
新的 mavenized 文件结构现在反映了前面提到的 git 存储库中的示例:
/tracker-webapp
/src
/main
/clojure
/tracker
/core.clj (and other *.clj files)
/webapp
/WEB-INF
/web.xml
/pom.xml
我的 web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
<display-name>Simple Clojure WebApp</display-name>
<servlet>
<servlet-name>myservlet</servlet-name>
<servlet-class>tracker.core</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>myservlet</servlet-name>
<url-pattern>/*</url-pattern>
</servlet-mapping>
</web-app>
其他资源
我本来打算发布我在本节中查看过的其他资源,但自从我是 Stack Overflow 新手,我只得到两个链接:/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要提前编译 clojure 命名空间 tracker.core (AOT)。我不确定这是如何使用 Maven 插件完成的,但它为您提供了正确的方向。
确保您的命名空间中有一个 gen-class 声明:
检查 Intellij/Maven 是否实际在目标目录中生成文件 tracker/core.class。
You need to compile your clojure namespace tracker.core ahead-of-time (AOT). I'm not sure how this is done with the maven plugin but it gives you the right direction.
Make sure that you have a gen-class declaration in your namespace:
Check that Intellij/Maven actually produce the file tracker/core.class in the target directory.