• Java web项目在linux环境下自动编译和部署脚本


    自动编译脚本 build.sh, 放置在项目根目录下。

    #!/bin/bash
    # check args
    # init path
    CURRPATH=`pwd`
    LIBDIR="$CURRPATH/WebContent/WEB-INF/lib"
    SRC="$CURRPATH/src"
    CLASS="$CURRPATH/WebContent/WEB-INF/classes"
    if [ -a $CLASS ]; then
            rm -rf $CLASS/*
    else
            mkdir $CLASS
    fi
    
    CLASSPATH="$CLASSPATH"
    TMP=`find $LIBDIR -name "*.jar" | awk '{var=$0":"var;}END{print var;}'`
    CLASSPATH="$TMP$CLASSPATH"
    echo "classes:$CLASS"
    javac -sourcepath $SRC -classpath $CLASSPATH -d $CLASS `find $SRC -name "*.java"`
    WebContent/deploy.sh

    自动部署脚本 deploy.sh,放置在WebContent/目录下。

    #!/bin/bash
    # check args
    PROJ="UFE"
    WAR="$PROJ.war"
    if [ $# -ne 1 ]; then
            TOMCAT="/usr/local/tomcat"
    else
            TOMCAT=$1
    fi
    BAK="$TOMCAT/bak"
    if [ -a $BAK ]; then
            ls $BAK
    else
            mkdir $BAK
    fi
    
    if [ -a $WAR ]; then
            rm -f $WAR
    fi
    WEBROOT=`pwd`
    if [ -a $WAR ]; then
            rm -f $WAR
    fi
    echo "jar -cvf $WAR "
    jar -cfM $WAR .
    BAKWAR="$BAK/$WAR"
    if [ -a $BAKWAR ]; then
            i=1
            while [[ -a $BAK/$WAR.$i ]]
            do
                    ((i++))
            done
            mv $BAKWAR $BAK/$WAR.$i
    fi
    $TOMCAT/bin/shutdown.sh
    DIS="$TOMCAT/webapps/$WAR"
    if [ -a $DIS ]; then
            mv $DIS $BAKWAR
            rm -f $DIS
    fi
    Folder="$TOMCAT/webapps/$PROJ"
    if [ -a $Folder ]; then
            rm -rf $Folder
    fi
    cp $WAR $DIS
    $TOMCAT/bin/startup.sh
  • 相关阅读:
    print格式化输出(format)
    Python list,tuple,dict,set高级变量常用方法
    K8s的kubectl常用命令
    C/C++中数组与指针的关系探究
    Java中的不可变类
    JAVA 类总结
    c++ string类find总结
    关于看板娘的事儿
    类型转换
    计算机2进制小数点表示法
  • 原文地址:https://www.cnblogs.com/dorothychai/p/4462701.html
Copyright © 2020-2023  润新知