日期:2014-05-16 浏览次数:20976 次
一、加大tomcat启动时的内存大小
(1)tomcat\bin目录下面的catalina.sh这个文件。
(2)
# Set juli LogManager if it is present
if [ -r "$CATALINA_HOME"/bin/tomcat-juli.jar ]; then
? JAVA_OPTS="$JAVA_OPTS -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
? LOGGING_CONFIG="-Djava.util.logging.config.file=$CATALINA_BASE/conf/logging.properties"
else
? # Bugzilla 45585
? LOGGING_CONFIG="-Dnop"
fi
# ----- Execute The Requested Command -----------------------------------------
?
#add by?duyf from 10.3.3.27
echo set JAVA_OPTS
JAVA_OPTS="$JAVA_OPTS -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=8139 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -Xms1024m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=512m"
echo JAVA_OPTS=$JAVA_OPTS
#add ends
?
# Bugzilla 37848: only output this if we have a TTY
if [ $have_tty -eq 1 ]; then
? echo "Using CATALINA_BASE:?? $CATALINA_BASE"
? echo "Using CATALINA_HOME:?? $CATALINA_HOME"
? echo "Using CATALINA_TMPDIR: $CATALINA_TMPDIR"
? if [ "$1" = "debug" -o "$1" = "javac" ] ; then
??? echo "Using JAVA_HOME:?????? $JAVA_HOME"
? else
??? echo "Using JRE_HOME:?????? $JRE_HOME"
? fi
fi
?
(3)或者下面这样的写法也可以。
CATALINA_OPTS="-Dcom.sun.management.jmxremote
-Dcom.sun.management.jmxremote.port=8839
-Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
-Xms512m
-Xmx1024m
-Djava.awt.headless=true"
export CATALINA_OPTS
DISPLAY="127.0.0.1:0.0"
export DISPLAY
?
#add by duyf
JAVA_OPTS="-server -Xms800m -Xmx800m -XX:PermSize=128M -XX:MaxNewSize=2048m -XX:MaxPermSize=2048m -Djava.awt.headless=true"
export? JAVA_OPTS
#end
# OS specific support.? $var _must_ be set to either true or false.
cygwin=false
os400=false
case "`uname`" in
CYGWIN*) cygwin=true;;
OS400*) os400=true;;
esac
?
二、项目放到tomcat下面来运行
(1)写个xml的配置文件放到D:\apache-tomcat-5.5.26\conf\Catalina\localhost下面,格式如下:
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="D:\project\momc2.0\java\moio\html" path="/moio" reloadable="false" privileged="true"/>
注意这里的docBase所指的目录是到WEB-INF这个目录的上面即可。因为WEB-INF这个目录下有classes源码。
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="D:\project\momc2.0\java\momc2" path="/momc2" reloadable="false" privileged="true"/>
或者这样
<?xml version="1.0" encoding="UTF-8"?>
<Context docBase="D:\solodu\workspace\momc3\WebRoot" path="/momc3" reloadable="false" privileged="true" antiResourceLocking="false" antiJARLocking="false"/>
?
(2)也可以这样来配置在tomcat/conf/server.xml文件里面:
<Context path="/momc" docBase="/mimsm/momc/test/momctest_szty"? debug="0"? reloadable="true" crossContext="true"/>
<Context path="/aaaa" docBase="/mimsm/momc/test/moiotest_szty" debug="0" reloadable="ture" crossContext="true"/>
在</Host>标签的上发紧挨着放即可!