一、免配置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>

  

免配置环境变量使用Tomcat+设置项目主页路径为http://localhost:8080+修改tomcat端口号的更多相关文章

  1. 在ASP.NET Core配置环境变量和启动设置

    在这一部分内容中,我们来讨论ASP.NET Core中的一个新功能:环境变量和启动设置,它将开发过程中的调试和测试变的更加简单.我们只需要简单的修改配置文件,就可以实现开发.预演.生产环境的切换. A ...

  2. ASP.NET Core配置环境变量和启动设置

    在这一部分内容中,我们来讨论ASP.NET Core中的一个新功能:环境变量和启动设置,它将开发过程中的调试和测试变的更加简单.我们只需要简单的修改配置文件,就可以实现开发.预演.生产环境的切换. A ...

  3. [转]ASP.NET Core配置环境变量和启动设置

    本文转自:https://www.cnblogs.com/tdfblog/p/Environments-LaunchSettings-in-Asp-Net-Core.html 在这一部分内容中,我们来 ...

  4. ionic2.2.1 配置环境变量及创建新项目

    1,jdk的安装与环境配置 jdk下载网址 http://www.oracle.com/technetwork/java/javase/downloads/index.html, jdk环境配置  A ...

  5. 在tomcat中的conf文件夹下找server.conf 配置如下代码,可省略项目名路径访问 如 localhost:8080 即可访问到项目

    <Context path="" docBase="C:\Workspaces\Projects\SLSaleSystem_dw\WebRoot" rel ...

  6. IDEA本地运行Hadoop程序配置环境变量

    1.首先到github上下载hadoop-common-2.2.0-bin-master 2.解压放到自定义目录下 再将hadoop.dll文件复制到windows/System32目录下 3.配置环 ...

  7. Linux CentOS7.0下JAVA安装和配置环境变量

    一.前言: CentOS7.0虽然自带JDK1.7和1.8,运行“java -version”命令也可以看到版本信息,但是jdk的安装环境不全,比如缺少tool.jar和dt.jar等,这就导致“ja ...

  8. Linux下发布javaWeb项目,配置环境变量,tomcat,和安装mysql数据库

    如果不懂,可以联系微博本人:QQ:3111901846 (原创) 1.配置java中jdk 注意一切操作,都是在root这个目录下进行的,不要选择其他目录,不然会出现一些小问题的 第一步: 你需要一个 ...

  9. tomcat是否有必要配置环境变量(摘)

    之前发表了一篇关于如何安装和配置Tomcat的文章,而最近在开发项目的时候总是报错.后来被公司的大神问了一句:是谁告诉你Tomcat是需要配置环境变量的? 作为新手的我瞬间整个人都不好了!于是偷偷百度 ...

随机推荐

  1. javascript获取客户端默认打印机

    JS <script language="javascript"> function startRequest() { var oShell = new ActiveX ...

  2. Rikka with Subset

    Rikka with Subset Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others ...

  3. (转)IOS崩溃 异常处理(NSSetUncaughtExceptionHandler)

    iOS已发布应用中对异常信息捕获和处理 代码下载地址:http://download.csdn.net/detail/daiyelang/6740205 iOS开发中我们会遇到程序抛出异常退出的情况, ...

  4. python函数的学习笔记

    这篇文章是我关于学习python函数的一些总结 一.随着函数的引入,这里首先要说的就是全局变量和局部变量了. 什么是全局变量.什么是局部变量: 全局变量就是全局都能调用的变量,一般都在文件的开头,顶头 ...

  5. angular2表单初体验

    1.创建movie模型. 最近对angular2比较感兴趣,跟着官网学习一段,练习了一个表单demo! src/app/movie.ts文件: export class Movie{ construc ...

  6. [BZOJ3551]Peaks

    [BZOJ3551]Peaks BZOJ luogu 建Kruskal重构树,点权为边权 按dfn序建出主席树 倍增找到能跳到的最浅的祖先 主席树查询一下 #include<bits/stdc+ ...

  7. ThinkPHP官网瀑布流实现分享

    很多人都想做瀑布流的效果,这里告诉大家官网使用的方法. 首先要下载瀑布流的插件jquery.masonry.min.js 地址:http://masonry.desandro.com/index.ht ...

  8. 通过实例来分析I2C基本通信协议

    本文旨在用最通俗易懂的方式.让大家明确I2C通信的过程到底是怎么回事. I2C起源于飞利浦公司的电视设计,但之后朝通用路线发展,各种电子设计都有机会用到I2C 总的来说,I2C能够简单归纳为,两根线, ...

  9. 中文价格识别为数字 java代码

    运行效果: public class VoicePriceRecognition { private final static String NOT_HAS_PRICE_CONTENT="n ...

  10. Android:日常学习笔记(8)———探究UI开发(5)

    Android:日常学习笔记(8)———探究UI开发(5) ListView控件的使用 ListView概述 A view that shows items in a vertically scrol ...