springboot命令启动
gradle打jar包命令
jar {
doFirst {
def jarFiles = '';
configurations.compile.collect {
jarFiles += it.name + " "
}
manifest {
attributes(
"Manifest-Version": "1.0",
"Class-Path": jarFiles,
"Main-Class": "com.test.TestApplication")
}
}
}
task deploy(type: Copy) {
doFirst {
println "cmd /c gradle clean".execute().text
println "cmd /c gradle build -x test".execute().text
}
from configurations.runtime
into "../jar"
from "build/libs/test-1.0-SNAPSHOT.jar"
into "../jar"
}
发布linux目录结构
1.jar存放所有jar文件
2.application.yml配置文件
server:
address: 192.168.1.100
port: 10001
3.logs.out日志文件,无内容
4.web配置文件
#!/bin/bash
case $1 in
start)
java -Dfile.encoding=UTF-8 -jar jar/test-1.0-SNAPSHOT.jar --spring.config.location=application.yml > logs.out &
;;
stop)
ps -ef|grep jar/test-1.0-SNAPSHOT* |grep -v grep |awk '{print $2}' | sed -e "s/^/kill -9 /g" | sh -
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
status) ps -ef|grep jar/test-1.0-SNAPSHOT*
;;
*)
echo "Example: lpservice.sh [start|stop|restart|status]" ;;
esac
启动项目直接使用脚本启动 sh web start && tail -200f logs.out
在windows下面运行 需要加一个 .bat 文件,文件内容如下,写完后直接双击 .bat 文件就可以启动项目
chcp 65001
java -jar -Dfile.encoding=UTF-8 jar/test-1.0-SNAPSHOT.jar --spring.redis.database=10 --server.port=8088 --server.address=test.com --test.staticPath=file:../code/