简体   繁体   中英

Why does Intellij-IDEA ignore my tomcat/conf/server.xml Context tag?

In my $TOMCAT_HOME/conf/server.xml I put this near the bottom:

...

 <Context path="/staticdir" docBase="/filesystem/path/to/static/dir"/>                                

      </Host>
    </Engine>
  </Service>
</Server>

I'm doing this because I have files on my filesystem that I want tomcat to serve up when you go to localhost:8080/staticdir

But when I start the application in Intellij-IDEA the tomcat log says this:

Using CATALINA_BASE: "C:\\Users\\me.IntelliJIdea11\\system\\tomcat\\Unnamed_Product_2"

If I go into that directory on my filesystem and look at the conf/server.xml file, it doesn't have the Context tag I put in there. Why is intellij modifying this and how can I prevent it?

I have a feeling I should have made this change to my $TOMCAT_HOME/conf/context.xml file instead, but I'm having trouble finding examples of how to make this change in there. If someone could show me an example of that, I'd consider it an answer, because I notice that intellij doesn't modify that file.


I have found a workaround.

在此处输入图片说明

But I really don't like this because when new users try to run the app for the first time, I can't imagine a way to detect they did this step incorrectly.

Here's a picture of my tomcat configuration:

在此处输入图片说明

默认情况下,IntelliJ IDEA修改CATALINA_BASE环境,以便Tomcat使用调整后的配置文件直接从工件输出位置部署应用程序,但是可以覆盖此行为并手动配置所有内容(通过将工件输出更改为进入webapps或更改与IDEA一样的服务器配置,以便从标准工件输出进行部署)。

I was need ROOT context in Tomcat/IntelliJ, so in server.xml in Host tag, add specific Context :

<Context path="" docBase="C:\intranet\app\tomcat\webapps\ROOT\" reloadable="true" />

In intelliJ 11.1.5, in Server tab panel check box "Deploy applications configured in Tomcat instance", IntelliJ will copy server.xml in folder deployment :

C:\Users\{Username}\.IntelliJIdea11\system\tomcat\Unnamed_Product_2\conf"

Now I can access to resources in Root domain, by example crossdomain.xml :

http://localhost:8080/crossdomain.xml

In Startup/Connection tab add the data as mentioned below in ' Pass environment variables ' section. Restart and that's it.

Name           Value
------------   -----
CATLINA_BASE   {Tomcat Installation directory}

I copied servers and found that my log files are stored in the wrong location.

So for the "Tomcat prod" it was actually using catalina.base=".../preprod/..."

I ended up editing projects/.idea/workspace.xml which was next to where I installed IntelliJ

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM