SpringBoot jar包部署及脚本启动

一、maven添加如下配置

 
        
            
                
                src/main/resources
                true
            
            
                
                src/main/config/${profiles.activation}
                true
            
        
        
            
            
                org.springframework.boot
                spring-boot-maven-plugin
                1.5.2.RELEASE
                
                    com.xxx.xxxx.ServerApplication
                
                
                    
                        
                            repackage
                        
                    
                
            
            
                org.apache.maven.plugins
                maven-jar-plugin
                
                    
                        
                            com.xxx.xxxx.ServerApplication
                            
                            lib/
                            true
                        
                        
                            resources/
                        
                    
                
            
            
                org.apache.maven.plugins
                maven-assembly-plugin
                
                    false
                    
                        src/main/assembly/assembly.xml
                    
                
                
                    
                        make-assembly
                        package
                        
                            assembly
                        
                    
                
            
        
        xxx-server
    

assembly.xml文件配置如下:



    package
    
    
        
        
    
    true
    
        
            src/main/resources
            /
        
        
            ${project.build.directory}
            /
            
                *.jar
            
        
    

二、启动脚本

#!/bin/bash

export JAVA_HOME=/usr/local/jdk1.8.0_161/
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=.:${JAVA_HOME}/bin:$PATH

nohup java -jar xxxxxxxxxxxxxxx.jar > /dev/null 2>&1 &

三、停止脚本

#!/bin/bash

PID=$(ps -ef | grep xxxxxxxxxxxxxxx.jar | grep -v grep | awk '{ print $2 }')
if [ -z "$PID" ]
then
    echo Application is already stopped
else
    echo kill $PID
    kill $PID
fi

 四、脚本意思

普通启动,关闭当前窗口,程序关闭(不推荐使用)
 java -jar xxxxxxxxxx.jar

后台启动命令
nohup java -jar xxx.jar > nohup.out  2>&1 &


后台启动命令将日志文件放到黑洞中
nohup java -jar xxxxxxxxx.jar > /dev/null 2>&1 &

你可能感兴趣的:(springboot,spring,boot,jar,java)