linux上Java Application程序启动脚本

在Java Application程序部署的步骤:


1、用maven导出依赖的全部jar包:

dependency:copy-dependencies


2、编译项目,将项目源码打成jar包,如果是web项目,一般打成war包。

clean:install


3、将项目拷贝到服务器上,以以下的脚本启动项目。


#!/bin/bash

#into the directory
cd Tap3Parse
# add all the jar
for loop in `ls ../dependency/*.jar`;do
        echo ${loop}
        export CLASSPATH=${loop}:${CLASSPATH}
done
nohup java com.mobile263.tap3.controller.Controller > ../parse.log&

关键点:将jar目录中扫描jar包,逐个加入到CLASSPATH里面。

加载完成后,CLASSPATH格式为:

../dependency/logback-core-1.1.2.jar:../dependency/logback-classic-1.1.2.jar:../dependency/log4j-over-slf4j-1.7.9.jar:../dependency/junit-4.11.jar:../dependency/jsch-0.1.44-1.jar:../dependency/jcl-over-slf4j-1.6.1.jar:../dependency/jboss-transaction-api_1.2_spec-1.0.0.Final.jar:../dependency/jboss-logging-annotations-1.2.0.Beta1.jar:../dependency/jboss-logging-3.1.3.GA.jar:../dependency/javassist-3.18.1-GA.jar:../dependency/jandex-1.1.0.Final.jar:../dependency/hibernate-validator-5.1.3.Final.jar:../dependency/hibernate-search-analyzers-3.4.2.Final.jar:../dependency/hibernate-search-3.4.2.Final.jar:../dependency/hibernate-jpa-2.1-api-1.0.0.Final.jar:../dependency/hibernate-entitymanager-4.3.10.Final.jar:../dependency/hibernate-core-4.3.10.Final.jar:../dependency/hibernate-commons-annotations-4.0.5.Final.jar:../dependency/hibernate-commons-annotations-3.2.0.Final.jar:../dependency/hibernate-c3p0-4.3.5.Final.jar:../dependency/hamcrest-core-1.3.jar:../dependency/fastjson-1.2.7.jar:../dependency/dom4j-1.6.1.jar:../dependency/commons-pool-1.5.4.jar:../dependency/commons-logging-1.2.jar:../dependency/commons-lang-2.5.jar:../dependency/commons-io-1.4.jar:../dependency/commons-dbcp-1.4.jar:../dependency/commons-compress-1.10.jar:../dependency/commons-codec-1.4.jar:../dependency/classmate-1.0.0.jar:../dependency/c3p0-0.9.2.1.jar:../dependency/aspectjweaver-1.8.5.jar:../dependency/asnrt-1.0.jar:../dependency/aopalliance-1.0.jar:../dependency/antlr-2.7.7.jar:


以冒号分割的路径。

你可能感兴趣的:(linux)