Java Eclipse 中运行的 Tomcat 实例的“work”目录在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/763693/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 19:11:58  来源:igfitidea点击:

Where is the "work" directory located for a Tomcat instance running in Eclipse?

javaeclipsejsptomcat

提问by Robert Campbell

In Eclipse you can configure numerous servers to run inside the IDE, including Tomcat. Depending on your Tomcat configuration, at some point in the life cycle of a webapp your JSP files will get compiled into servlets. These new servlet .classfiles are stored in the %TOMCAT_HOME%/workdirectory along with the .javaintermediate file created from the JSP. This .javafile is very helpful when your JSPs throw exceptions and cite a line number corresponding to the .javaand not the .jsp

在 Eclipse 中,您可以配置许多服务器以在 IDE 内运行,包括 Tomcat。根据您的 Tomcat 配置,在 web 应用程序生命周期的某个时刻,您的 JSP 文件将被编译为 servlet。这些新的 servlet .class文件%TOMCAT_HOME%/work与从 JSP 创建的.java中间文件一起存储在该目录中。当您的 JSP 抛出异常并引用对应于.java而不是.jsp的行号时,此.java文件非常有用

Update:On my environment (Windows), it is located here:

更新:在我的环境 (Windows) 中,它位于此处:

C:/Documents and Settings/%USER%/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/work

C:/Documents and Settings/ %USER%/ workspace / .metadata / .plugins / org.eclipse.wst.server.core / tmp0 / work

Perhaps to answer more completely somebody could post the location for *nix environments.

也许为了更完整地回答,有人可以发布 *nix 环境的位置。

采纳答案by Parag

You will find it in

你会在

projectworkspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0

This is the default place where Eclipse 3.4 publishes the project. However, this can be changed by changing the settings in your 'Server' view.

这是 Eclipse 3.4 发布项目的默认位置。但是,这可以通过更改“服务器”视图中的设置来更改。

回答by JW.

I assume it would be the same location relative to your workspace.

我假设它相对于您的工作区是相同的位置。

回答by Peter ?tibrany

You can change it by setting scratchDir parameter in web.xml configuration of your server (in Servers project, not in your application web.xml!).

您可以通过在服务器的 web.xml 配置中设置 scratchDir 参数来更改它(在服务器项目中,而不是在您的应用程序 web.xml 中!)。

回答by Thorbj?rn Ravn Andersen

The easiest way is most likely to ask a compiled JSP page about the source of the byte code.

最简单的方法是向编译后的 JSP 页面询问字节码的来源。

From http://www.exampledepot.com/egs/java.lang/ClassOrigin.html:

http://www.exampledepot.com/egs/java.lang/ClassOrigin.html

// Get the location of this class
Class cls = this.getClass();
ProtectionDomain pDomain = cls.getProtectionDomain();
CodeSource cSource = pDomain.getCodeSource();
URL loc = cSource.getLocation();  // file:/c:/almanac14/examples/

Hopefully this helps. What is it you want to do?

希望这会有所帮助。你想做什么?

回答by sourcerebels

Go to "Servers" window -> double click on your tomcat instance -> clik "Open launch configuration" -> go to "Arguments" tab.

转至“服务器”窗口 -> 双击您的 tomcat 实例 -> 单击“打开启动配置”-> 转至“参数”选项卡。

Look for variable definition like this:

寻找这样的变量定义:

-Dcatalina.base="/Users/dirtyaffairs/Documents/workspace/.metadata/.plugins/org.eclipse.wst.server.core/tmp0"

回答by sv.

  1. On Windows, the easiest way to go to your Eclipse's Tomcat deployment location is to just right-click on the Tomcat instance in the Serversview and click "Browse Deployment Location..."

    You should see Eclipse neatly opening a Windows explorer taking you to the exact location. In my case it takes me to:

    C:\eclipse4.3.2-jee-kepler-SR2-win32\workspaces\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps

    From there, you can easily browse to the "work" directory as shown below.

    If you follow this, you never have to remember the location!

    Eclipse Servers View:

    enter image description here

    Windows Explorer Opens:

    enter image description here

    Windows Explorer (click on address bar to reveal full path):

    enter image description here

  2. On Amazon EC2 Linux(this has nothing to do with Eclipse however), the Tomcat workdirectory is at /var/cache/tomcat7/work

    [ec2-user@ip-172-31-xx-xx ~]$ uname -a
    Linux ip-172-31-xx-xx 4.1.10-17.31.amzn1.x86_64 #1 SMP Sat Oct 24 01:31:37 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
    
    [root@ip-172-31-xx-xx] /usr/share/tomcat7 $ ls -l
    total 4
    drwxr-xr-x 2 root root   4096 Jan  5 15:18 bin
    lrwxrwxrwx 1 root tomcat   12 Jan  5 15:18 conf -> /etc/tomcat7
    lrwxrwxrwx 1 root tomcat   23 Jan  5 15:18 lib -> /usr/share/java/tomcat7
    lrwxrwxrwx 1 root tomcat   16 Jan  5 15:18 logs -> /var/log/tomcat7
    lrwxrwxrwx 1 root tomcat   23 Jan  5 15:18 temp -> /var/cache/tomcat7/temp
    lrwxrwxrwx 1 root tomcat   24 Jan  5 15:18 webapps -> /var/lib/tomcat7/webapps
    lrwxrwxrwx 1 root tomcat   23 Jan  5 15:18 work -> /var/cache/tomcat7/work
    
    [root@ip-172-31-xx-xx] /var/cache/tomcat7/work/Catalina/localhost/init/org/apache/jsp $ ls -la
    total 180
    drwxr-xr-x 2 tomcat tomcat  4096 Jan  6 06:37 .
    drwxr-xr-x 3 tomcat tomcat  4096 Jan  6 06:37 ..
    -rw-r--r-- 1 tomcat tomcat 54172 Aug 17  2012 index_jsp.class
    -rw-r--r-- 1 tomcat tomcat  2106 Jan  6 06:37 index_jsp$FileComp.class
    -rw-r--r-- 1 tomcat tomcat  1034 Jan  6 06:37 index_jsp$FileInfo.class
    -rw-r--r-- 1 tomcat tomcat  6460 Jan  6 06:37 index_jsp$HttpMultiPartParser.class
    -rw-r--r-- 1 tomcat tomcat 89445 Aug 17  2012 index_jsp.java
    -rw-r--r-- 1 tomcat tomcat  2210 Jan  6 06:37 index_jsp$UplInfo.class
    -rw-r--r-- 1 tomcat tomcat  1208 Jan  6 06:37 index_jsp$UploadMonitor.class
    -rw-r--r-- 1 tomcat tomcat  1184 Jan  6 06:37 index_jsp$Writer2Stream.class
    
  1. Windows 上,转到 Eclipse 的 Tomcat 部署位置的最简单方法是在“服务器”视图中右键单击Tomcat 实例,然后单击“浏览部署位置...

    您应该会看到 Eclipse 整齐地打开一个 Windows 资源管理器,将您带到确切的位置。就我而言,它需要我:

    C:\eclipse4.3.2-jee-kepler-SR2-win32\workspaces\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps

    从那里,您可以轻松浏览到“工作”目录,如下所示。

    如果你遵循这个,你永远不必记住位置!

    Eclipse 服务器视图:

    在此处输入图片说明

    Windows 资源管理器打开:

    在此处输入图片说明

    Windows 资源管理器(单击地址栏以显示完整路径):

    在此处输入图片说明

  2. Amazon EC2 Linux 上(但这与 Eclipse 无关),Tomcat工作目录位于/var/cache/tomcat7/work

    [ec2-user@ip-172-31-xx-xx ~]$ uname -a
    Linux ip-172-31-xx-xx 4.1.10-17.31.amzn1.x86_64 #1 SMP Sat Oct 24 01:31:37 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
    
    [root@ip-172-31-xx-xx] /usr/share/tomcat7 $ ls -l
    total 4
    drwxr-xr-x 2 root root   4096 Jan  5 15:18 bin
    lrwxrwxrwx 1 root tomcat   12 Jan  5 15:18 conf -> /etc/tomcat7
    lrwxrwxrwx 1 root tomcat   23 Jan  5 15:18 lib -> /usr/share/java/tomcat7
    lrwxrwxrwx 1 root tomcat   16 Jan  5 15:18 logs -> /var/log/tomcat7
    lrwxrwxrwx 1 root tomcat   23 Jan  5 15:18 temp -> /var/cache/tomcat7/temp
    lrwxrwxrwx 1 root tomcat   24 Jan  5 15:18 webapps -> /var/lib/tomcat7/webapps
    lrwxrwxrwx 1 root tomcat   23 Jan  5 15:18 work -> /var/cache/tomcat7/work
    
    [root@ip-172-31-xx-xx] /var/cache/tomcat7/work/Catalina/localhost/init/org/apache/jsp $ ls -la
    total 180
    drwxr-xr-x 2 tomcat tomcat  4096 Jan  6 06:37 .
    drwxr-xr-x 3 tomcat tomcat  4096 Jan  6 06:37 ..
    -rw-r--r-- 1 tomcat tomcat 54172 Aug 17  2012 index_jsp.class
    -rw-r--r-- 1 tomcat tomcat  2106 Jan  6 06:37 index_jsp$FileComp.class
    -rw-r--r-- 1 tomcat tomcat  1034 Jan  6 06:37 index_jsp$FileInfo.class
    -rw-r--r-- 1 tomcat tomcat  6460 Jan  6 06:37 index_jsp$HttpMultiPartParser.class
    -rw-r--r-- 1 tomcat tomcat 89445 Aug 17  2012 index_jsp.java
    -rw-r--r-- 1 tomcat tomcat  2210 Jan  6 06:37 index_jsp$UplInfo.class
    -rw-r--r-- 1 tomcat tomcat  1208 Jan  6 06:37 index_jsp$UploadMonitor.class
    -rw-r--r-- 1 tomcat tomcat  1184 Jan  6 06:37 index_jsp$Writer2Stream.class