如何在 Eclipse、Tomcat 和 Tomcat 下将 .java 文件更改传播为 .class条纹

发布于 2024-08-26 20:55:37 字数 997 浏览 7 评论 0原文

我是java新手,遇到了一些问题。我正在 tomcat 6.0 上使用框架 stripes 开发一个 Web 应用程序。 我正在 Windows 上使用 Eclipse EE。我成功地在我的 tomcat 服务器上启动并运行了 stripes 示例应用程序(称为 Bugzooky)。我在 Eclipse 中导入了 .war 文件和 stripes 库。 这是条纹包含示例和库的存档


但现在我正在尝试更改示例源文件以了解它是如何工作的。但无论对源文件“WebContent/WEB-INF/src/*.java”进行何种修改,都没有任何变化!即使重新启动服务器后。我注意到这些类被编译成“ImportedClasses”文件夹中的.class文件,并且tomcat总是使用这些文件,它们永远不会更新,如果我删除其中之一,应用程序就不会启动。我的源文件似乎不存在!


我还尝试从头开始构建我的 web 应用程序,但是当我尝试使用示例文件中使用的功能(如 SecurityFilter.java)时:

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import ...

它最终会得到很多:

the import javax.servlet.Filter cannot be resolved

我检查了库,看起来我正在使用确切的功能与示例相同。


这可能是我对java不理解的地方,但我昨天用谷歌搜索了100次,但找不到解决方案(我可能没有搜索到正确的地方,因为我并不真正理解我的问题)。

我希望你能帮助我。

i'm new to java and i got some problems. i'm developping a web application using the framework stripes on tomcat 6.0.
I'm working with eclipse EE on windows. i successfully managed to get the stripes example application (called Bugzooky) up and running on my tomcat server. I imported the .war file and stripes libs in Eclipse.
Here is the stripes archive containing the examples and libs


But now i'm trying to change the example source files to learn how does it work. but whatever the modification made to the source files "WebContent/WEB-INF/src/*.java", nothing change! even after restarting the server. i noticed that the classes are compiled into .class files in the "ImportedClasses" folder, and tomcat always use these files, they are never updated, and if i removed one of them, the application just don't start. it look like my source files don't exists!


I also tried to build my webapp from scratch, but when i tried to use the features used in the example files (like SecurityFilter.java):

import javax.servlet.Filter;
import javax.servlet.FilterChain;
import javax.servlet.FilterConfig;
import ...

It ends up with plenty of:

the import javax.servlet.Filter cannot be resolved

I checked the Librairies and it look like i'm using exactly the same as the example.


It's probably something i didn't understood about java but i googled 100 times yesterday, and i can't find the solution (i probably didn't search the right place because i don't really understand my problem).

I hope you'll be able to help me.

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

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

发布评论

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

评论(2

倒数 2024-09-02 20:55:37

我不确定第一个问题。关于新建项目时出现的问题:

导入 javax.servlet.Filter 无法解析

这意味着 Eclipse 中的 Web 项目不与应用程序服务器关联。如果正确完成,Eclipse 将自动在项目的构建路径中包含服务器的库(服务器实际上是每个 Servlet API 下的具体实现)。

你把Tomcat集成到Eclipse了吗?您可以在右下框的“服务器”视图中添加服务器。您是否将该 Web 项目与特定的 Tomcat 实例关联起来?您需要在项目属性目标运行时部分中选择服务器。顺便说一句,这通常是在创建动态 Web 项目期间完成的。

I'm not sure about the first problem. With regard to the problem when creating a new project:

the import javax.servlet.Filter cannot be resolved

This means that the web project in Eclipse is not associated with an application server. If this is done correctly, then Eclipse will automatically include the server's libraries (the server is actually a concrete implementation of under each the Servlet API) in the project's buildpath.

Did you integrate Tomcat in Eclipse? You can add servers in the Servers view at the right bottom box. Did you associate the web project with the particular Tomcat instance? You need to select the server in the Targeted Runtimes section of the project's Properties. This is by the way normally to be done during creating the Dynamic Web Project.

冷血 2024-09-02 20:55:37

您需要重新编译所有更改的 .java 文件,重建 .war 文件并将其重新部署到 Tomcat。使用 Ant 构建脚本可以最轻松地完成此操作。查找名为 build.xml 的文件。如果存在,请安装 Ant(如果您尚未安装),然后只需执行 <在包含 build.xml 文件的目录中执行 code>ant 命令,然后将生成的 .war 文件复制到 Tomcat 中的现有文件上。这是所有基本的 Java 应用程序服务器工作流程内容。

You need to recompile all the changed .java files, rebuild the .war file and redeploy it to Tomcat. This is most easily done with an Ant build script. Look for a file called build.xml. If it is there install Ant if you don't already have it installed and you can then just execute the ant command in the directory with the build.xml file and then copy the resulting .war file over the existing one in Tomcat. This is all basic Java App server work flow stuff.

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