使用 Eclipse 和 Tomcat 开发 Scala/Lift Web 应用程序

发布于 2024-09-19 18:48:21 字数 1905 浏览 3 评论 0原文

因此,我花了过去 11 个小时尝试通过 Eclipse 在 Tomcat 上运行最简单的 Scala/Lift 应用程序。显然没有人试图这样做,或者这是世界上最简单的事情,所以没有人记录他们是如何做到的。使用 Maven 原型创建代码并使用 mvn tomcat:run 运行它是没有问题的。通过 Eclipse 实现这一切是另一回事。我想说这是我第一次尝试在 Eclipse 中使用 Maven 做任何事情,但没有任何帮助。我尝试过 m2eclipse 和 eclipse-IAM。如果有人可以引导我从头到尾完成整个过程,或者为我指出可用的资源,那就太好了。谢谢。


版本/错误详细信息

Scala 2.8 with Lift 2.1

如果我将 Scala 2.8 with Lift 2.1(?) 与 eclipse 3.5.2、scala-ide 和 eclipse-iam 一起使用,我的 pom.xml 文件会告诉我这一点:

错误:解析“org.scala-tools:maven-scala-plugin”版本时出错:插件需要 Maven 版本 2.2.1

我使用此原型定义从 Maven 项目创建向导创建了该项目:

<archetype>
    <groupId>net.liftweb</groupId>
    <artifactId>lift-archetype-blank_2.8.0</artifactId>
    <version>2.1-SNAPSHOT</version>
    <repository>http://scala-tools.org/repo-snapshots</repository>
    <description>Shawn's Custom Thinger</description>
</archetype>

据我了解,问题在这里是从 2.1-SNAPSHOT 创建的 pom.xml 文件需要 Maven 2.2.1,但 eclipse-iam 尚未使用该版本。我还没有找到一种方法来使用我自己安装的Maven v2.2.1。据说 eclipse-iam 不允许使用外部 maven 安装。

其他尝试

我尝试过使用此原型构建项目:

<archetype>
    <groupId>net.liftweb</groupId>
    <artifactId>lift-archetype-jpa-blank</artifactId>
    <version>1.1-SNAPSHOT</version>
    <repository>http://scala-tools.org/repo-snapshots</repository>
    <description>Archetype - blank JPA project for Lift</description>
</archetype>

但是,然后我从 Tomcat 收到运行时错误,因为我的 bootstrap.liftweb.Boot 类出现 ClassNotFound 错误。但是,我可以看到 maven 为我创建了一个默认的 Boot 类。

m2eclipse

我使用 m2eclipse 得到了一个没有错误的项目,但在将其部署到 Tomcat 上时遇到了问题。我打算重新审视这个项目,因为我很好奇我是否确实设法让一个项目正常运行,但当我尝试它时,URL 中出现了区分大小写的问题。然而,这个过程需要更多的手动操作。如果可能的话,我更喜欢 eclipse-iam 解决方案,但会采取我目前能得到的解决方案。

So I have spent the past 11 hours now trying to get even the simplest Scala/Lift app to run on Tomcat through Eclipse. Apparently no one is trying to do this or it is the easiest thing in the world so no one has documented how they did it. Creating the code using a maven archetype and running it with mvn tomcat:run is no problem. Making it all work through Eclipse is another story. I will say this is my first attempt to do anything with Maven in Eclipse which has not helped any. I have tried both m2eclipse and eclipse-IAM. If anyone could walk me through the process from start to finish or point me to resources that can, that would be great. Thanks.


Version/Error Details

Scala 2.8 with Lift 2.1

If I use Scala 2.8 with Lift 2.1(?) with eclipse 3.5.2, scala-ide, and eclipse-iam, my pom.xml file tells me this:

Error: Error resolving version for 'org.scala-tools:maven-scala-plugin': Plugin requires Maven version 2.2.1

I created the project from the Maven Project Creation Wizard using this archetype definition:

<archetype>
    <groupId>net.liftweb</groupId>
    <artifactId>lift-archetype-blank_2.8.0</artifactId>
    <version>2.1-SNAPSHOT</version>
    <repository>http://scala-tools.org/repo-snapshots</repository>
    <description>Shawn's Custom Thinger</description>
</archetype>

From what I understand, the problem here is the pom.xml file created from the 2.1-SNAPSHOT requires Maven 2.2.1, but eclipse-iam does not use that version yet. I have not managed to find a way to use the Maven v2.2.1 that I have installed myself. Supposedly eclipse-iam does not allow use of an external maven install.

Other Attempts

I have tried building projects with this archetype:

<archetype>
    <groupId>net.liftweb</groupId>
    <artifactId>lift-archetype-jpa-blank</artifactId>
    <version>1.1-SNAPSHOT</version>
    <repository>http://scala-tools.org/repo-snapshots</repository>
    <description>Archetype - blank JPA project for Lift</description>
</archetype>

However, then I get runtime errors from Tomcat for a ClassNotFound error for my bootstrap.liftweb.Boot class. However, I can see that maven created a default Boot class for me.

m2eclipse

I got a project with no errors using m2eclipse, but I was having problems getting it deployed on Tomcat. I intend to revisit this one as I am curious if I did manage to get one project working, but had a case-sensitivity problem in the URL when I tried it. However, this process was much more manual. I would prefer an eclipse-iam solution if possible, but will take what I can get at this point.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

紧拥背影 2024-09-26 18:48:21

我无法描述我对同一问题的沮丧。最后,唯一对我有用的文件是这个:
http://www.spenceruresk.com/2010/10/ Development-with-lift-in-eclipse/

我认为 m2eclipse-scala 插件制作区别。

I can't begin to describe my frustration with the same issue. Finally the only document that worked for me is this one:
http://www.spenceruresk.com/2010/10/developing-with-lift-in-eclipse/

I think m2eclipse-scala plugin made the difference.

像你 2024-09-26 18:48:21

您为什么想通过 Eclipse 运行您的 Web 应用程序?使用 Maven Tomcat 插件 (mvn tomcat:run) 启用调试 (JPDA) 来运行它不是更容易吗?然后用Eclipse远程调试器连接它?

恕我直言,这是运行/调试使用 Maven 构建的 JVM 应用程序的最简单、最灵活和通用的方法。

另请参阅 - 使用 Eclipse 和 Maven 调试打包为 WAR 的 Java Web 应用程序的最佳方法?

Why would you like to run your webapp through Eclipse? Isn't easier to just run it on using Maven Tomcat plugin (mvn tomcat:run) with debug (JPDA) enabled? And then connect to it with Eclipse remote debugger?

IMHO the is the easiest, most flexible and generic way of running/debugging JVM applications built with Maven.

See also - Best way to debug Java web application packaged as a WAR using Eclipse and Maven? .

柏林苍穹下 2024-09-26 18:48:21

也许你可以编辑“test/scala/RunWebApp.scala”从jetty到tomcat。
以我的经验,通过“mvn eclipse:eclipse”生成项目文件。在 Eclispe 中,只需使用“Debug As...”运行“test/scala/RunWebApp.scala”,不再需要 JRebel 或 maven。

Maybe you can edit "test/scala/RunWebApp.scala" from jetty to tomcat.
With my experience, after "mvn eclipse:eclipse" to generate project files. In Eclispe just run "test/scala/RunWebApp.scala" with "Debug As...", no JRebel or maven need anymore.

眼睛会笑 2024-09-26 18:48:21

您应该能够通过运行 mvn eclipse:eclipse 生成本机 Eclipse 项目。上次我尝试时,效果相对较好。请注意,您将需要 Eclipse 的 scala 插件。

You should be able to generate a native eclipse project through running mvn eclipse:eclipse. This worked relatively well the last time I tried it. Note that you will need the scala plugin for Eclipse.

当梦初醒 2024-09-26 18:48:21

未找到类听起来像是战争(无论是否爆炸)不包含 scala jar,或者可能包含 lift jar。

Class not found sounds like the war (exploded or not) doesn't contain the scala jar, or possibly the lift jars.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文