IDEA如何打出war包

上一篇博文未讲完了IDEA的项目,突然感觉还有什么没讲对!是有关tomcat的部分,jsp只能在tomcat启动时运行。所以这篇博文主要讲idea的项目如何在tomcat上调试和发布。

1.IDEA集成tomcat

1)在新生成的web项目中点击这个按钮。
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131171027452.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
2)建立本地的服务器
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131171357599.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
3)创建项目的名称
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131171441686.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
在大圆中写上要输出的项目名称,一定要提前改,否则后来改很麻烦
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131171521509.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)

2.在IDEA中打出war包

war包:Web application Archive,与jar基本相同,但它通常表示这是一个Java的Web应用程序的包,tomcat这种Servlet容器会认出war包并自动部署。
1)点击这个
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131190850189.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
或者
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131190951571.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
2)创建空的Artifacts
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131191040531.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
3)配置Artifacts
改名字
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131191214279.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131191252665.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
选择前端的根目录
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131191304739.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
创建WEB-INF的目录,并在该目录下创建classes目录
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131191407842.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131191518445.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
给classes配置后端代码:
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131191530723.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
点击OK
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131191624505.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
点击ok即可
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131191705170.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
buildwar包
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131191806377.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131191826114.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
在相应的文件中找到war包
![在这里插入图片描述]( https://img-blog.csdnimg.cn/2020013119185869.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)

3.在tomcat中发布war包

1)将war包复制到tomcat的webapps中
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131192042618.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
2)打开bin中的start.bat
![在这里插入图片描述]( https://img-blog.csdnimg.cn/20200131192141330.png?x-oss-process=image/watermark ,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2pvZXlfcm8=,size_16,color_FFFFFF,t_70)
3)war包自动解压
输入对应的url即可.

posted @ 2020-02-02 17:16  大石林牙  阅读(8876)  评论(0)    收藏  举报