Java应用程序工程模板
时间:2011-04-05 51cto博客 leizhimin
自己常用的一个java应用程序模板,节省了不少时间!
包含很多脚本:
一、启动脚本
starup.bat
set APP_LIBDIR=..\lib
setlocal EnableDelayedExpansion
set APP_CLASS_PATH=%XFIRE_HOME%
for %%c in ("%APP_LIBDIR%\*.jar") do set APP_CLASS_PATH=! APP_CLASS_PATH!;%%c
set APP_CLASS_PATH
java -cp %APP_CLASS_PATH% com.lavasoft.TestMain
startup.sh
#!/bin/sh
programdir="."
program="com.lavasoft.TestMain"
num=$#
temp=$CLASSPATH
#setting libs path
libs=../lib/*
append(){
temp=$temp":"$1
}
for file in $libs; do
append $file
done
export CLASSPATH=$temp:.:../:$programdir
export LANG=zh_CN
res=`ps aux|grep java|grep $program|grep -v grep|awk ''{print $2}''`
if [ -n "$res" ]
then
echo "TestMain already running"
else
java -classpath $CLASSPATH com.lavasoft.TestMain &
sleep 3
unset res
res=`ps aux|grep java|grep $program|grep -v grep|awk ''{print $2}''`
if [ -n "$res" ]
then
echo "TestMain start success"
else
echo "TestMain start error"
fi
fi
Java哘喘殻會垢殻庁医(2)
扮寂:2011-04-05 51cto鴬人 leizhimin
屈、log4j.properties
log4j.rootLogger=INFO,CONSOLE,LOGFILE
## CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.Threshold=INFO
log4j.appender.CONSOLE.Target=System.out
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss } - %-5p %c %x - %m%n
## logfile
log4j.appender.LOGFILE=org.apache.log4j.RollingFileAppender
log4j.appender.LOGFILE.File=testapp.log
log4j.appender.LOGFILE.MaxFileSize=10MB
log4j.appender.LOGFILE.MaxBackupIndex=10
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout
log4j.appender.LOGFILE.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss } - %-p %c %x - %m%n
眉、build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project name="testapp" basedir="." default="compile">
<property environment="env"/>
<property name="build.dir" value="./testapp"/>
<property name="classes.dir" value="${build.dir}/bin"/>
<property name="dist.dir" value="./testapp"/>
|