Intellij IDEA 2017配置TomCat 9.0服务
作者:
丿记忆灬永殇丨 | 来源:发表于
2017-09-20 20:42 被阅读2210次
本文介绍在IntelliJ IDEA 2017里配置本地的TomCat 9.0服务器,前提是TomCat 9.0服务器已经正确安装并配置(TomCat 9.0服务器下载、安装与配置教程)。
在Intellij IDEA 2017中配置TomCat 9.0:
依次打开File > Settings > Build, Execution, Deployment > Application Servers,点击“+”,选择TomCat Server:

选择TomCat Server
选择本地已经安装的TomCat服务器,若正确配置过TomCat系统环境变量,则IDEA会自动检测到,否则手动指定TomCat位置:

选择本地TomCat
添加成功,点击“OK”:

正确添加
点击靠右侧边栏的三角形,点击Edit Configurations,或者打开菜单栏Run > Edit Configurations:

编辑配置
点击“+”号,依次选择TomCat Server > Local:

添加local服务器
为本地的TomCat服务器设置名称。下方出现一个“Warning”,点击“Fix”按钮即可进行自动修复,或者切换到“Deployment”选项卡进行手动修复,这里演示如何进行手动修复:

修复问题
切换到“Deployment”选项卡,点击“+”,点击“Artifact”:

选择Artifact
建议修改Application Context为“/项目名”,即设置项目虚拟路径(上下文路径),即在地址栏上的访问地址。若默认“/”,则当启动TomCat启动后访问项目的index.jsp,在浏览器地址栏应输入http://localhost:8080/index.jsp
;若设置为“/项目名”,则为http://localhost:8080/项目名/index.jsp
:

修改虚拟路径
切回至“Server”,在“Open Browser”设置里,
建议勾选上“After Launch”,意思为当启动TomCat后,自动打开浏览器并运行项目,此时同样可以在别的浏览器手动输入地址进行访问。
建议将“On 'Update' action”和“On frame deactivation”设置为“Update classes and resources”,这样当修改项目内容时会自动更新字节码文件和资源文件,避免反复重启TomCat服务器:

修改配置
当需要启动或停止TomCat服务器时,只需点击绿色三角形(启动)或者红色正方形(关闭)即可:

使用TomCat
至此,Intellij IDEA 2017已成功配置TomCat 9.0服务器!
本文标题:Intellij IDEA 2017配置TomCat 9.0服务
本文链接:https://www.haomeiwen.com/subject/knugsxtx.html
网友评论