Eclipse和如何处理JARS - 奇案例 [英] Eclipse and How it Handles JARS -- Odd Case

查看:174
本文介绍了Eclipse和如何处理JARS - 奇案例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

试图让一些小的修改Apache的Velocity引擎。

Trying to make some small changes to Apache's Velocity engine.

这就是我能做和不能做的。

Here's what I can and can't do.

我做了更改合并功能()。我正在做的改变并不重要,因为我还没有做呢。 ;)现在我满足于一个println语句,射击

I'm making a change to the merge function(). The change I'm making doesn't matter because I haven't made it yet. ;) Right now I am settling for a println statement firing.

我有两个引用合并()。如果我改变的功能mergeBAD()的Eclipse告诉我,它无法找到合并()。有道理吗?我曾经在我的课的构建路径,包括两个罐子,你下载的速度时,你得到,而是我已经使用所提供的SRC文件创建一个项目,并使用该项目作为一个依赖。再次,这是事实无法找到合并(),当我重新命名为mergeBAD给了我希望。

I have two references to merge(). If I change the function to mergeBAD() Eclipse tells me that it can't find merge(). Makes sense right? I used to include in my class build path the two jars that you get when downloading velocity but instead I've created a project using the src files provided and used THAT project as a dependency. Again, the fact that is can't find merge() when I rename it to mergeBAD gives me hope.

但是,当我运行我的Web服务器,打一个断点,单步合并呼叫,它无法找到出处!我将它指向该项目再次,它认定的源头,没有我所做的更改(特别是println语句)被击中。他们只是跳过。 (

But when I am running my web server, hit a breakpoint and step into the merge call, it can't find the source! I point it to the project yet again, and it "finds" the source, none of the changes I've made (specifically the println statements) are hit. They are simply skipped over. :(

这是上帝的绿色地球怎么可能会导致这?它的驾驶我疯狂。我花了整整一天今天试图找出什么是错的。我不能继续没有能够改变速度。究竟是什么code基地日食从运行速度文件?

What on God's green earth could possibly be causing this? It's driving me insane. I've spent the entire day today trying to figure out what's wrong. I can't continue without being able to change Velocity. Exactly what code base is eclipse running the velocity files from?

提前这么多的感谢! :)

Many thanks in advance SO! :)

推荐答案

这是混乱的一个典型案例的构建类路径运行时类路径

This is a typical case of confusion between build classpath and runtime classpath.

您的构建类路径的包含(包含变更速度)你的Java项目引用...但我敢打赌,你的运行时类路径的持有到原来的速度JAR文件的引用

Your build classpath contains references to your Java project (containing the changes to Velocity)... but I bet your runtime classpath holds references to the original Velocity JAR files.

管理构建Eclipse下的Web项目的类路径运行时类路径的(在WTP - Web工具项目)已通过大规模的变化会在过去的几年WTP释放。我们可以指导你。如果你身体补充速度的JAR文件到您的 WEB-INF / lib目录,允许将其取出即可启动。

Managing build classpath and runtime classpath in Web projects under Eclipse (the WTP - Web Tools Project) has been going through massive changes over the last few WTP releases. We can guide you through. If you physically added Velocity's JAR files into your WEB-INF/lib, lets start by removing them.

OK,您从 WEB-INF / lib目录 Velocity.jar 文件后,请执行以下操作:

OK, after you remove the Velocity.jar file from WEB-INF/lib, do the following:


  1. 右键单击该项目,选择属性。

  2. 转至Java构建路径。选择项目选项卡,并确保您的自定义速度的项目(可以称之为MyVelocity)是的的存在。

  3. 仍然在Java构建路径,选择库选项卡,并确保没有速度JAR有两种。

遵循上面的步骤,我们从任何到MyVelocity(项目)或任何其他速度JAR任何参考清理你的web应用程序。

By following the steps above, we cleaned your Web-App from any reference whatsoever to MyVelocity (your project) or any other Velocity JAR.

现在到了有趣的部分。我会教你如何正确的依赖关系增加的Java项目,Web项目。

Now comes the fun part. I will instruct you how to correctly "add" Java projects to Web projects as dependencies.


  1. 仍然在项目的属性,转至部署大会

  2. 单击添加。

  3. 选择项目,然后下一步。

  4. 选择MyVelocity,并确保网络图书馆参考复选框被选中。

  5. 单击完成。

早在部署大会对话框,您现在应该看到 MyVelocity 映射到 WEB -INF / lib目录/ MyVelocity.jar

Back in the Deployment Assembly dialog, you should now see MyVelocity mapped into WEB-INF/lib/MyVelocity.jar.

点击确定。

我们所做的通过是MyVelocity映射为 WEB-INF / lib目录依赖。通过这样做, MyVelocity 将被自动添加到编译时构建路径,以及 - 因此它的非常的重要,你不加它自己的构建路径,造成重复建设路径条目。

What we did by that is to map MyVelocity as a WEB-INF/lib dependency. By doing that, MyVelocity is automatically added to the compile-time build-path as well - so it is very important that you don't add it yourself to the build-path, resulting in duplicate build-path entries.

一切都应该为你现在的工作。让我知道如果你有任何问题。

Everything should work for you now. Let me know if you have any problems.

P.S。这些说明,如果你正在开发一个独立的WAR项目正确的;如果你的WAR文件是EAR的一部分,你可能(如 MyVelocity 由其他J2EE模块耳内在某些情况下,例如)要映射 MyVelocity 不同,一个共同的位置;如果是这样的话,让我知道,我会进一步阐述。

P.S. these instructions are correct if you're developing a stand-alone WAR project; if your WAR file is a part of an EAR, you may wish (under certain circumstances, for example if MyVelocity is used by other J2EE modules inside the EAR) to map MyVelocity differently, to a common location; if that's the case, let me know and I'll elaborate further.

这篇关于Eclipse和如何处理JARS - 奇案例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆