将项目放到服务器tomcat上运行
2017-03-27 09:55
316 查看
一、进入maven项目主目录执行mvn clean package 打war包(在pom.xml中配置打jar还是war,jar是自带容器,war则需要在其他容器中才能运行,生成的war会在target下) 二、将生成的war放入服务器上tomcat主目录(在bin中执行./startup.sh会自动生成服务器使用项目) 三.这时的访问需要加上端口和项目名(项目名就是服务器生成的文件夹名称)
如果在访问时,想去掉项目名称可以进行以下配置
一、将生成的项目放入ROOT中 二、配置tomcat <Engine name="Catalina" defaultHost="localhost"> <!--For clustering, please take a look at documentation at: /docs/cluster-howto.html (simple how to) /docs/config/cluster.html (reference documentation) --> <!-- <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> --> <!-- Use the LockOutRealm to prevent attempts to guess user passwords via a brute-force attack --> <Realm className="org.apache.catalina.realm.LockOutRealm"> <!-- This Realm uses the UserDatabase configured in the global JNDI resources under the key "UserDatabase". Any edits that are performed against this UserDatabase are immediately available for use by the Realm. --> <Realm className="org.apache.catalina.realm.UserDatabaseRealm" resourceName="UserDatabase"/> </Realm> <Host name="localhost" appBase="webapps" unpackWARs="true" autoDeploy="true"> <Context path="" docBase="/usr/local/apache/tomcat/tomcat-kun/webapps/xuetang-1.0-SNAPSHOT" debug="0" reloadable="true" /> //配置改路径后访问时只需要输入端口便可以访问 <!-- SingleSignOn valve, share authentication between web applications Documentation at: /docs/config/valve.html --> <!-- <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> --> <!-- Access log processes all example. Documentation at: /docs/config/valve.html Note: The pattern used is equivalent to using pattern="common" --> <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log" suffix=".txt" pattern="%h %l %u %t "%r" %s %b" /> </Host> </Engine>
扩展:以上需要使用tomcat启动
可以自己配置启动脚本如下tomcat-kun.sh
# tomcat8081Æô¶¯¶Ë¿Ú TOMCAT1_HOME=/usr/local/apache/tomcat/tomcat-kun #tomcat的主目录 start_tomcat=$TOMCAT1_HOME/bin/startup.sh #tomcat 启动项目开关路径 stop_tomcat=$TOMCAT1_HOME/bin/shutdown.sh #tomcat 关闭项目开关路径 start(){ #启动 echo -n "Starting tomcat1:" #提示语 ${start_tomcat} echo "tomcat8081 start ok" #提示语 } stop(){ #关闭 echo -n "Shutdown tomcat" #提示语 ${stop_tomcat} echo "tomcat8081 stop ok" #提示语 } case "$1" in start) start ;; stop) stop ;; restart) stop sleep 10 start ;; *) echo "Usage: $0 {start|stop|restart}" esac exit 0
脚本可放置在任意地方(注意:该脚本需要转换为ULIX格式)
使用这种脚本启动的方法: 进入到该脚本目录 sh tomcat-kun.sh start 使用这种脚本关闭的方法: 进入到该脚本目录 sh tomcat-kun.sh stop
相关文章推荐
- 将项目放到服务器tomcat上运行
- java 运行项目不放到tomcat下的webapps文件夹下放到自己建的文件夹中的处理办法
- 部署Eclipse中的Web项目到Tomcat服务器运行
- Tomcat中部署运行JavaWeb项目( 解决JRE_HOME 路径缺少影响的服务器启动问题)
- Eclipse中通过Tomcat运行J2EE项目java.lang.OutOfMemoryError: PermGen space的解决方案_Tomcat服务器
- 阿里云服务器CentOS7配置Java Web项目运行环境(MySql,Tomcat,Jre)
- 服务器Tomcat运行Java项目 80 433 端口被占用 解决方案
- Tomcat 服务器运行 隐藏项目名
- Tomcat 服务器只能存有一个正在运行的项目
- 14.把eclipse中的web项目打包成war包,然后再Tomcat服务器中运行。
- 在Eclipse中运行项目时,Tomcat服务器下项目名后面多出了括号且括号中名称与项目名不一致
- 用spring+struts2+hibernate开发的项目放到服务器上时由于服务器不能联网,启动tomcat报错。
- 在eclipse中怎么运行j2ee项目到tomcat服务器中
- 当你的JavaEE项目运行时tomcat服务器总是提示not suitable driver之类
- 在asp.net2.0项目在vs2005下运行没问题,放到IIS下就出现"服务器应用程序不可用",为什么?在asp.net2.0项目在vs2005下运行没问题,放到IIS下就出现"服务器应用程序不可用",为什么?
- 服务器上用Tomcat运行jsp项目与服务器上tomcat域名解析外网访问-史上最详细的
- 用项目运行在自己编译好的tomcat服务器上
- 图示如何创建tomcat服务器,运行项目
- 【tomcat】服务器上运行SSH的项目
- java 运行项目不放到tomcat下的webapps文件夹下放到自己建的文件夹中的处理办法