好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

Intellij idea下使用不同tomcat编译maven项目的服务器路径方法详解

问题出现原因:

使用自己下载的tomcat运行maven项目,其中有图片上传模块,图片全部上传到target目录下的工程文件里。结果使用maven的clean插件时,图片全部被删除。

目录如下:

为了解决这个问题,想了如下几种方法:

更改output directory目录 tomcat 增加虚拟目录。但intellij idea里的工程运行的是 catalina.sh run 命令,工程外的文件路径访问不到 在第2种方法的基础上,同时运行tomcat/bin/startup.sh脚本,但比较麻烦。 将图片保存到在线服务器,使用ip访问地址(最终部署到服务器使用)。 最后看到使用 maven-tomcat-plugin 插件部署工程的方法,试了一下,发现一个问题,这种使用tomcat插件的方式和用自己配置的tomcat所获取的服务器路径不一样!

使用自己配置tomcat上传的路径为:

使用maven-tomcat插件上传的路径为:

区别为:

原因:

自己配置的tomcat的output directory为target目录,而maven-tomcat插件的目录为工程的目录:

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

<!-- maven tomcat plugin -->

<plugin>

   <groupid>org.apache.tomcat.maven</groupid>

   <artifactid>tomcat7-maven-plugin</artifactid>

   <version> 2.2 </version>

   <configuration>

    <!--deploy to server-->

    <url>http: //localhost:8080/manager/text</url>

    <server>tomcat- 8.0 . 29 </server>

    <username>admin</username>

    <password>admin</password>

    <path>/crowfunding</path>

    <port> 8080 </port>

   </configuration>

</plugin>

总结

以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,谢谢大家对的支持。如果你想了解更多相关内容请查看下面相关链接

原文链接:https://blog.csdn.net/u012099869/article/details/50449422

查看更多关于Intellij idea下使用不同tomcat编译maven项目的服务器路径方法详解的详细内容...

  阅读:10次