简体   繁体   English

我该如何访问 <tomcat> 从Eclipse内部运行时的\\ bin \\ *。属性?

[英]How can I access <tomcat>\bin\*.properties when running from inside eclipse?

Does anyone know if Tomcat running inside of Eclipse truly uses the <tomcat>\\bin\\ directory when you've configured your server to use your local Tomcat install (Server view) inside Eclipse? 当您将服务器配置为在Eclipse内部使用本地Tomcat安装(服务器视图)时,是否有人知道在Eclipse内部运行的Tomcat是否真正使用<tomcat>\\bin\\目录?

For example: I'm using a colleagues jar, which subsequently requires the X.properties file. 例如:我正在使用同事jar,后来需要X.properties文件。 I've been instructed to place that properties file in the <tomcat>\\bin\\ directory. 我已被指示将该属性文件放在<tomcat>\\bin\\目录中。 This is sort of odd to me, but the line that fails is simply: 这对我来说有点奇怪,但失败的路线很简单:

InputStream in = new FileInputStream("X.properties");

Anyhow, I'm pretty sure editing any of the Server config files will not help me, though I'm open to any suggestions. 无论如何,我很确定编辑任何服务器配置文件都无法帮助我,尽管我对任何建议持开放态度。 Or perhaps there's something in my launch configuration (below) that I can change? 或者也许在我的启动配置(下面)中我可以更改某些内容?

在此输入图像描述

No matter what, I get the following stack trace: 无论如何,我得到以下堆栈跟踪:

java.io.FileNotFoundException: X.properties (The system cannot find the file specified)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:106)
    at java.io.FileInputStream.<init>(FileInputStream.java:66)
    at com.mycompany.myteam.colleaguesproject.colleaguesservlet.init(colleaguesservlet.java:93)
    at javax.servlet.GenericServlet.init(GenericServlet.java:212)
    at org.apache.catalina.core.StandardWrapper.loadServlet(StandardWrapper.java:1139)
    at org.apache.catalina.core.StandardWrapper.load(StandardWrapper.java:966)
    at org.apache.catalina.core.StandardContext.loadOnStartup(StandardContext.java:3956)
    at org.apache.catalina.core.StandardContext.start(StandardContext.java:4230)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardHost.start(StandardHost.java:736)
    at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1014)
    at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
    at org.apache.catalina.core.StandardService.start(StandardService.java:448)
    at org.apache.catalina.core.StandardServer.start(StandardServer.java:700)
    at org.apache.catalina.startup.Catalina.start(Catalina.java:552)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:585)
    at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:295)
    at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:433)

Any help is greatly appreciated! 任何帮助是极大的赞赏! :-) :-)

Java designates the directory that you started it from as its 'working directory', and any relative paths are relative to that directory. Java将您启动它的目录指定为“工作目录”,并且任何相对路径都相对于该目录。 In this case, that's Tomcat's bin directory, which contains Tomcat's startup script. 在这种情况下,这是Tomcat的bin目录,其中包含Tomcat的启动脚本。

You should put the properties file in C:\\apache-tomcat-5.5.25\\bin to make this work, though this is not a good practice for java properties files. 您应该将属性文件放在C:\\ apache-tomcat-5.5.25 \\ bin中以使其工作,尽管这对于java属性文件来说不是一个好习惯。 Reading them in off of Java's classpath is standard, and much more flexible. 在Java的类路径中读取它们是标准的,并且更加灵活。

I totally agree with mblinn ! 我完全同意mblinn!

Eclipse creates a local instance of tomcat server, for which eclipse.exe is the Main application. Eclipse创建了一个tomcat服务器的本地实例,其中eclipse.exe是Main应用程序。

Try placing your X.properties file in eclipse root folder. 尝试将您的X.properties文件放在eclipse根文件夹中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 从 Eclipse 运行 Tomcat 6 时出现 ClassCircularityError - ClassCircularityError when running Tomcat 6 from Eclipse 从Eclipse运行tomcat - Running tomcat from eclipse 从eclipse启动时看不到Tomcat主页(http:// localhost:8080)。 但是,当我从tomcat bin目录启动它时会加载它。 有什么想法吗? - Cannot see Tomcat homepage( http://localhost:8080) when starting it from eclipse. But it loads when I start it from tomcat bin directory. Any idead? Eclipse在运行tomcat时未检测到任何错误,但找不到bean - Eclipse detects no errors but can't find bean when running tomcat 如何在启动时将tomcat服务器运行的属性写入Java logback日志? - How can I write to my java logback log the properties the tomcat server is running with on startup? 如何在 eclipse 之外运行的 Tomcat web 应用程序中执行热代码替换? - How can I perform Hot Code Replace in Tomcat web application running outside eclipse? 仅当从eclipse和tomcat运行时,LoadLibrary才会失败 - LoadLibrary fails only when running from eclipse & tomcat 从Eclipse运行Tomcat时避免Permgen Space错误 - Avoid Permgen Space error when running Tomcat from Eclipse 在 eclipse 中运行的 tomcat 和在服务器上运行的 tomcat 有什么区别? - What is the difference between tomcat running inside eclipse and tomcat running on a server? 从Eclipse内部启动Tomcat Mongrel插件时发生致命错误 - Fatal error when starting Tomcat mongrel plugin from inside eclipse
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM