装了tomcat后发现tomcat安装在系统跟路径地下,每次部署的时候挺麻烦的,于是想指定一个自己定义的应用部署的路径:

以下是如何指定,相关文档请查看https://tomcat.apache.org/tomcat-4.1-doc/appdev/deployment.html

注意你的tomcat的版本,我在网上查的时候由于自己的版本是7.0.6,而部署的方法有几个版本,3.1和4.1就不一样

先讲我自己的是7.0.6版本部署方式是打开tomcat的根目录在conf文件夹底下修改server.xml文件在 最下面的</Host>标签上面添加一个指定docBase路径的

context flag:如

<Context path="" docBase="~/Documents/javaProject/webapps/"  reloadable="true" />

注意两个小细节:

  一个是指定docBase时不要忘记了这个docBase是一个文件夹所以如上webapps后面要加上/

  另外一个是docBase下要有一个WEB-INF文件夹结构里面的结构和tomcat跟目录底下的webapps的一致。

这样以后你的java class 和application 依赖的jar包就可以分别放在这个WEB-INF文件夹底下的class和lib下了

现在讲讲3.1版本的tomcat是怎么弄的:

3.1版本的tomcat也是添加context flag,但是添加的位置是在tomcatroot/conf文件夹下的apps.xml中,由于有可能这个文件夹底下没有这个文件

这时候你需要自己创建一个这样的文件创建完后再往里面添加

  <?xml version="1.0" encoding="ISO-8859-1"?>
<webapps>
 <Context path="" docBase="~/Documents/javaProject/webapps/"  reloadable="true" />
</webapps>
这样就好了(由于我的是7.0.6版本所以没有试成功) 补充一下 用tomcat部署的应用可以指定的几个属性(都是用context flag来配置的)

path:这个是指定访问哪个web应用用的
docBase:指定你发布的应用程序在哪里
debug:跟tomcat的log相关
reloadble:设置为true,tomcat会自动检测你WEB-INF/class下的class文件或WEB-INF/lib中的jar包是否有新的更新,如果有的话tomcat会自动关闭并将更新加载完后重启(大概意思是这样的) trusted:访问tomcat内部类(一般情况是管理员对tomcat的操作) 翻译都是什么鬼(见原文:)
    • path. The context path for your application, which is the prefix of a request URI that tells Tomcat which application should be used to process this request. For example, if you set your path to "/catalog", any request URI beginning with "/catalog" will be processed by this application. This attribute is requrired, and must start with a slash ('/') character.
    • docBase. The document root directory for this web application. This can be a relative path (relative to the directory in which Tomcat is started), or an absolute path, to the directory containing your app. On a Windows platform, you MUST use the drive prefix and a colon when specifying an absolute path. This attribute is required.
    • debug. Debugging detail level (from "0" to "9") that defines how verbose Tomcat's logging messages will be when your application is initialized, started, and shut down. The default value is "0" (minimal logging) if you do not specify a different value.
    • reloadable. Set to "true" if you want Tomcat to watch for changes to Java class files in the WEB-INF/classes directory, or JAR files in the WEB-INF/lib directory. If such a change is noted, Tomcat will shut down and reload your application automatically, picking up these changes. The default value ("false") means that such changes will be ignored. NOTE: While this feature is very useful during development, it requires overhead to do the checking. This capability should generally not be used in deployed production applications.
    • trusted. Set to "true" if this application requires access to Tomcat 3.3 internal classes. Normally, this will only be required for the administration application that ships with Tomcat.

如何制定tomcat部署时自己定义的docBase路径的更多相关文章

  1. Tomcat部署时war和war exploded的区别

    转自徐刘根的Tomcat部署时war和war exploded区别以及平时踩得坑 一.war和war exploded的区别 在使用IDEA开发项目的时候,部署Tomcat的时候通常会出现下边的情况: ...

  2. tomcat 部署时修改服务器时间

    tomcat 在部署时修改了服务器时间  会出现以下状况 1.session 失效 2.修改的文件不会正确被tomcat热部署进去

  3. IDEA Tomcat部署时war和war exploded区别以及平时踩得坑

    war和war exploded的区别 在使用IDEA开发项目的时候,部署Tomcat的时候通常会出现下边的情况: 是选择war还是war exploded 这里首先看一下他们两个的区别: war模式 ...

  4. 170223、Tomcat部署时war和war exploded区别以及平时踩得坑

    war和war exploded的区别 在使用IDEA开发项目的时候,部署Tomcat的时候通常会出现下边的情况: 是选择war还是war exploded 这里首先看一下他们两个的区别: war模式 ...

  5. Tomcat部署时war和war exploded区别及验证

    war和war exploded的区别 在使用IDEA开发项目的时候,部署Tomcat的时候通常会出现下边的情况: 是选择war还是war exploded 这里首先看一下他们两个的区别: war模式 ...

  6. IDEA中Tomcat部署时war和war exploded区别

    原理说明 war模式:将WEB工程以包的形式上传到服务器 :war exploded模式:将WEB工程以当前文件夹的位置关系上传到服务器: 含义解释 war模式这种可以称之为是发布模式,看名字也知道, ...

  7. Tomcat部署时war和war exploded区别以及平时踩得坑

    war和war exploded的区别 在使用IDEA开发项目的时候,部署Tomcat的时候通常会出现下边的情况: 是选择war还是war exploded 这里首先看一下他们两个的区别: war模式 ...

  8. Tomcat部署时war和war exploded区别以及打包后路径问题

    感谢原文作者:keven_deng 原文链接:https://blog.csdn.net/keven_deng/article/details/104830664 war和war exploded的区 ...

  9. JDK和Tomcat部署时,版本不同的问题解决

    问题: 在以Tomcat作为Web容器,启动java Web工程时,遇到下面问题:org.eclipse.jdt.internal.compiler.classfmt.ClassFormatExcep ...

随机推荐

  1. 第19/24周 锁升级(Lock Escalations)

    大家好,欢迎回到性能调优培训.上2个星期我们已经讨论了SQLServer里的悲观和乐观锁.今天我想谈下SQL Server里对于锁的一个特殊现象:所谓的锁升级(Lock Escalations).在我 ...

  2. HT for Web 3D游戏设计设计--汉诺塔(Towers of Hanoi)

    在这里我们将构造一个基于HT for Web的HTML5+JavaScript来实现汉诺塔游戏. 汉诺塔的游戏规则及递归算法分析请参考http://en.wikipedia.org/wiki/Towe ...

  3. openjudge7834:分成互质组 解析报告

    7834:分成互质组 总时间限制:  1000ms 内存限制:  65536kB 描述 给定n个正整数,将它们分组,使得每组中任意两个数互质.至少要分成多少个组? 输入 第一行是一个正整数n.1 &l ...

  4. 了解WP的传感器

    之前看到老大的一个QQ签名,说想写一个WP的程序,可是后来,后来就没有后来了.我去年打算学一下WP程序开发的,一年了也无任何进展,我可不想后来,后来就没有后来.于是抽时间来接触一下.虽然都是用CShs ...

  5. c#使用WebClient登录网站抓取登录后的网页

    C#登录网站实际上就是模拟浏览器提交表单,然后记录浏览器响应返回的会话Cookie值,再次发送请求时带着这个会话cookie值去请求就可以实现模拟登录的效果了. 如下类CookieAwareWebCl ...

  6. iOS App上架AppStore 会遇到的坑

    前言部分 前言:非原创 文章摘自:http://zhuanlan.zhihu.com/100000PM/20010725 相信大家一定非常「深恶痛疾」AppStore的一系列产品上架规则.每次产品上架 ...

  7. Topshelf + ServiceModelEx + Nlog 从头构建WCF

    前言 Topshelf可以很方便的构建windows service,而且在本地开发时也可以构建Console宿主,因此很方便WCF的开发. ServiceModelEx则提供了很多便利的方法来配置w ...

  8. html5学习笔记(3)--主题结构元素-1

    Article元素 以下为对应代码: <!DOCTYPE html> <html> <head lang="en"> <meta char ...

  9. 安装Sublime Text 3汉化插件

    一.Sublime Text工具介绍: Sublime Text 是一个代码编辑器(Sublime Text 2是收费软件,但可以无限期试用),也是HTML和散文先进的文本编辑器.Sublime Te ...

  10. 轻量级权限管理系统(renren-security)

    renren-security是一个轻量级权限管理系统,其核心设计目标是开发迅速.学习简单.轻量级.易扩展.使用renren-security搭建项目,只需编写30%左右代码,其余的代码交给系统自动生 ...