Skip to content

Instantly share code, notes, and snippets.

@GeekaholicLin
Last active December 15, 2016 06:01
Show Gist options
  • Select an option

  • Save GeekaholicLin/7f51440f77c83df886ca22717fff4523 to your computer and use it in GitHub Desktop.

Select an option

Save GeekaholicLin/7f51440f77c83df886ca22717fff4523 to your computer and use it in GitHub Desktop.
[config--IDEA]改变IDEA中JSP的发布目录

~~~参考: http://stackoverflow.com/questions/13862032/change-default-web-application-directory-in-intellij-12~~~

~~~设置到Tomcat的目录~~~

---
update:

经过一个下午的摸索,终于搞清了IDEA中Tomcat的设置。

## 设置发布目录

为了方便在IDEA的Tomcat关闭后,系统再次启动Tomcat后仍然可以正常访问网站。`ctrl+shift+alt+s`打开`Project Structure`,在`Artifacts`菜单中添加一个`WebApplication Exploded`
,`From Modules`,选择已经存在的`modules`。然后将Output directory 指向你的tomcat安装目录的`webapps`下的任意一个文件夹【可以是不存在的】。
~~~在这里为了启动方便,
设置为`D:\tomcat\webapps\ROOT`,但是为了不覆盖,请将原来的ROOT改为`tomcat`。~~~
每个modules对应一个网站,所以,需要设置不同的目录。比如


> 1. D:\tomcat\webapps\servletConfig1
  2. D:\tomcat\webapps\servletConfig2
  



这样就会Output到两个目录下。



## 项目启动设置

1. 新建一个tomcat server,在Server的TAB下设置`open browser`为`http://localhost: [tomcat port] `。【这个是run的时候自动打开的地址】


~~~2. 在Deploment的TAB下设置添加刚刚已经设置的发布目录,Application context为`/`。~~~

2.  Application context为访问的根地址,比如设置为'/bookstore',则需要在地址栏打上'localhost:port/bookstore'进行访问


3. 为了将生成对应的selvert java类放到tomcat的`work`目录下,在`Startup/Connection` 的 TAB 设置`environment valiables`环境变量。Name为CATALINA_BASE,value为D:\tomcat 

4. 点击Ok对以上设置进行保存。

## Enjoy it!

若有不准确的地方,望指出。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment