一、免配置jdk JAVA_HOME和tomcat  CATALINA_HOME环境变量使用tomcat

  众说周知,使用tomcat需要有java环境,一般情况下需要配置jdk和tomcat的路径到windows系统的环境变量中。但是也可以不用配置环境变量,直接编辑tomcat的startup.bat文件即可,下面是TOMCAT安装路径bin目录下的startup.bat中的代码,红色字体就是配置了。其实这种方法适用于其它程序,例如:MAVEN的配置,maven运行也需要JAVA_HOME,可以在maven的bin目录下的mvn.cmd中做类似的配置即可。

  

@echo off
rem Licensed to the Apache Software Foundation (ASF) under one or more
rem contributor license agreements. See the NOTICE file distributed with
rem this work for additional information regarding copyright ownership.
rem The ASF licenses this file to You under the Apache License, Version 2.0
rem (the "License"); you may not use this file except in compliance with
rem the License. You may obtain a copy of the License at
rem
rem http://www.apache.org/licenses/LICENSE-2.0
rem
rem Unless required by applicable law or agreed to in writing, software
rem distributed under the License is distributed on an "AS IS" BASIS,
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
rem See the License for the specific language governing permissions and
rem limitations under the License. rem ---------------------------------------------------------------------------
rem Start script for the CATALINA Server
rem --------------------------------------------------------------------------- setlocal rem ---------当前bat文件目录的上级--------
set CATALINA_HOME=%~dp0.. rem -----------setclasspath.bat中要用到JAVA_HOME----------
set JAVA_HOME=E:\Program Files\Java\jdk1.8.0_131 rem Guess CATALINA_HOME if not defined
set "CURRENT_DIR=%cd%"
if not "%CATALINA_HOME%" == "" goto gotHome
set "CATALINA_HOME=%CURRENT_DIR%"
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
cd ..
set "CATALINA_HOME=%cd%"
cd "%CURRENT_DIR%"
:gotHome
if exist "%CATALINA_HOME%\bin\catalina.bat" goto okHome
echo The CATALINA_HOME environment variable is not defined correctly
echo This environment variable is needed to run this program
goto end
:okHome set "EXECUTABLE=%CATALINA_HOME%\bin\catalina.bat" rem Check that target executable exists
if exist "%EXECUTABLE%" goto okExec
echo Cannot find "%EXECUTABLE%"
echo This file is needed to run this program
goto end
:okExec rem Get remaining unshifted command line arguments and save them in the
set CMD_LINE_ARGS=
:setArgs
if ""%1""=="""" goto doneSetArgs
set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1
shift
goto setArgs
:doneSetArgs call "%EXECUTABLE%" start %CMD_LINE_ARGS% :end
pause

二、设置项目主页路径为http://localhost:8080、修改tomcat端口号

  tomcat文件夹下的conf文件夹下有个server.xml,port后面的数字就是端口号,修改就好了(有三个),如果只是修改访问端口(如:http://localhost:8080),只需要修改第二个就可以了。

  通过添加<Context path="" docBase="E:\Program Files\apache-tomcat-8.0.37\webapps\fire360-3.0" debug="0" reloadable = "true" />这一行,来修改tomcat的主页路径为项目的主页。

<?xml version='1.0' encoding='utf-8'?>

<Server port="8006" shutdown="SHUTDOWN">
<Listener className="org.apache.catalina.startup.VersionLoggerListener" />
<Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
<Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
<Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
<Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> <GlobalNamingResources>
<Resource name="UserDatabase" auth="Container"
type="org.apache.catalina.UserDatabase"
description="User database that can be updated and saved"
factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
pathname="conf/tomcat-users.xml" />
</GlobalNamingResources> <Service name="Catalina">
<Connector port="8081" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
<Engine name="Catalina" defaultHost="localhost">
<Realm className="org.apache.catalina.realm.LockOutRealm">
<Realm className="org.apache.catalina.realm.UserDatabaseRealm"
resourceName="UserDatabase"/>
</Realm> <Host name="localhost" appBase="webapps"
unpackWARs="true" autoDeploy="true"> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log" suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" /> <Context path="" docBase="E:\Program Files\apache-tomcat-8.0.37\webapps\fire360-3.0" debug="0" reloadable = "true" /> </Host>
</Engine>
</Service>
</Server>

  

最新文章

  1. Protobuf使用规范分享
  2. 利用TortoiseSVN获取最新版本的OpenCV源码
  3. ubuntu软件推荐
  4. 【转载】Linux启动过程
  5. AD批量创建用户
  6. for循环计算游戏通关分数
  7. .NET Framework Execution Was Aborted By Escalation Policy
  8. YouTube技术架构
  9. iOS开发——数据持久化Swift篇&amp;(一)NSUserDefault
  10. UVaLive 7270 Osu! Master (统计)
  11. ext combobox getValue
  12. iphone匹配邮箱的正则表达式
  13. 浅谈js闭包
  14. grok 正则解析日志例子&lt;1&gt;
  15. HDOJ 1598 Kruscal
  16. 数据库中的T-sql语句 条件修改 高级查询
  17. 关于 tomcat 配置时遇到的问题与警告及解决办法
  18. python爬虫爬取京东、淘宝、苏宁上华为P20购买评论
  19. oracle数据库查询语句case的用法
  20. search() 方法解析

热门文章

  1. sublime Text的一些用法(emmet插件、)
  2. WordArray (An array of 32-bit words.
  3. MySQL中自适应哈希索引
  4. 给俺的 CSDN 博客加背景音乐 - 高大尚的《心经》背景音乐
  5. Python获取位数
  6. PowerDesigner数据模型(CDM—PDM)
  7. 百度地图sn计算方法说明
  8. 【WEB HTTP】缓存
  9. JavaScript Promise异步实现章节的下载显示
  10. django-admin 设计User外键,设计model