build: 优化打包

This commit is contained in:
xiongxiaoyang 2022-07-14 09:49:36 +08:00
parent 40a999f353
commit c45b81fbbf
21 changed files with 545 additions and 518 deletions

View File

@ -224,67 +224,36 @@
<!--<scope>provided</scope>-->
<!--</dependency>-->
</dependencies>
<!-- <build>
<plugins>
&lt;!&ndash;<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>&ndash;&gt;
&lt;!&ndash;SpringBoot项目默认使用spring-boot-maven-plugin要打成被其他项目引用的jar包需要更换此插件&ndash;&gt;
&lt;!&ndash; <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>&ndash;&gt;
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>-->
<!-- <build>
<plugins>
&lt;!&ndash;<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>&ndash;&gt;
&lt;!&ndash;SpringBoot项目默认使用spring-boot-maven-plugin要打成被其他项目引用的jar包需要更换此插件&ndash;&gt;
&lt;!&ndash; <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>&ndash;&gt;
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>-->
<build>
<plugins>
<plugin>
<!--打包时去除第三方依赖-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
<includes>
<include>
<groupId>non-exists</groupId>
<artifactId>non-exists</artifactId>
</include>
</includes>
</configuration>
</plugin>
<!--拷贝第三方依赖文件到指定目录-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!--target/lib是依赖jar包的输出目录根据自己喜好配置-->
<outputDirectory>target/lib</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
<includeScope>runtime</includeScope>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
@ -298,28 +267,24 @@
<configuration>
<tasks>
<!-- 文件夹 -->
<copy todir="${project.build.directory}/build/conf" overwrite="true">
<fileset dir="${basedir}/src/main/resources">
<include name="**/*.*"/>
<exclude name="mybatis/*/*.*"/>
<copy todir="${project.build.directory}/build/config" overwrite="true">
<fileset dir="${basedir}/src/main/build/config">
<include name="*.*"/>
</fileset>
</copy>
<move todir="${project.build.directory}/build/lib">
<fileset dir="target/lib"/>
</move>
<copy file="${project.build.directory}/${project.artifactId}-${project.version}.jar"
tofile="${project.build.directory}/build/${project.artifactId}.jar" />
tofile="${project.build.directory}/build/${project.artifactId}.jar"/>
<fixcrlf srcdir="${basedir}/src/main/build/scripts" eol="unix"/>
<copy todir="${project.build.directory}/build/bin">
<fileset dir="${basedir}/src/main/build/scripts">
<include name="*.sh" />
<include name="*.txt" />
<include name="*.bat" />
<include name="*.sh"/>
<include name="*.txt"/>
<include name="*.bat"/>
</fileset>
</copy>
<zip destfile='${project.build.directory}/build/${project.artifactId}.zip'>
<zipfileset filemode="755" dir= '${project.build.directory}/build/' />
<zipfileset filemode="755" dir='${project.build.directory}/build/'/>
</zip>
</tasks>
</configuration>

View File

@ -0,0 +1,10 @@
#端口号
server:
port: 8088
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456

View File

@ -0,0 +1,94 @@
#!/bin/sh
APP_NAME=novel-admin
JAR_NAME=$APP_NAME\.jar
#PID 代表是PID文件
PID=$APP_NAME\.pid
#使用说明,用来提示输入参数
usage() {
echo "Usage: ./novel-admin.sh [start|stop|restart|status]"
exit 1
}
#检查程序是否在运行
is_exist(){
pid=`ps -ef|grep $JAR_NAME|grep -v grep|awk '{print $2}' `
#如果不存在返回1存在返回0
if [ -z "${pid}" ]; then
return 1
else
return 0
fi
}
#启动方法
start(){
is_exist
if [ $? -eq "0" ]; then
echo ">>> 小说精品屋后台正在运行 PID = ${pid} <<<"
else
echo ">>> 小说精品屋后台开始启动 <<<"
nohup java -jar -Dspring.profiles.active=prod $JAR_NAME >/dev/null 2>&1 &
sleep 20
echo $! > $PID
echo ">>> 小说精品屋后台启动完成 PID = $! <<<"
status
fi
}
#停止方法
stop(){
#is_exist
pidf=$(cat $PID)
#echo "$pidf"
echo ">>> 小说精品屋后台 PID = $pidf 开始停止 <<<"
kill $pidf
rm -rf $PID
sleep 2
is_exist
if [ $? -eq "0" ]; then
echo ">>> 小说精品屋后台 PID = $pid 开始强制停止 <<<"
kill -9 $pid
sleep 2
status
else
status
fi
}
#输出运行状态
status(){
is_exist
if [ $? -eq "0" ]; then
echo ">>> 小说精品屋后台正在运行 PID = ${pid} <<<"
else
echo ">>> 小说精品屋后台没有运行 <<<"
fi
}
#重启
restart(){
stop
start
}
#根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
"start")
start
;;
"stop")
stop
;;
"status")
status
;;
"restart")
restart
;;
*)
usage
;;
esac
exit 0

View File

@ -1,8 +0,0 @@
1linux启动环境
sh start.sh
3windows启动环境
windows-start.bat
3linux停止应用
sh stop.sh

View File

@ -1,47 +0,0 @@
#!/bin/bash
ENGINE=novel-admin.jar
cd ../
#部署目路
DEPLOY_DIR=`pwd`
#获取到当前目录的名称
SERVER_NAME=`basename $DEPLOY_DIR`
#应用进程
PIDS=`ps -ef | grep java | grep "$ENGINE" |awk '{print $2}'`
#设置日志文件的输出目录
LOGS_DIR=$DEPLOY_DIR/logs
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
#日志
STDOUT_FILE=$LOGS_DIR/stdout.log
#JAVA 环境配置
JAVA_OPTS=" -Djava.net.preferIPv4Stack=true -Dlog.home=$LOGS_DIR"
JAVA_MEM_OPTS=" -server -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:InitiatingHeapOccupancyPercent=50 -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCDateStamps -verbose:gc -XX:+PrintGCDetails -XX:+PrintHeapAtGC -Xloggc:$LOGS_DIR/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof "
#退出标志
RETVAL="0"
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit $RETVAL
fi
nohup java -jar $JAVA_OPTS $JAVA_MEM_OPTS -Dloader.path=conf,lib $ENGINE > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
if [ $COUNT -gt 0 ]; then
break
fi
done
echo "OK!"
PIDS=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'`
echo "PID: $PIDS"
echo "STDOUT: $STDOUT_FILE"

View File

@ -1,33 +0,0 @@
#!/bin/bash
SERVER_NAME=novel-admin.jar
#应用进程
PIDS=`ps -ef | grep java | grep "$SERVER_NAME" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in $PIDS ; do
PID_EXIST=`ps -f -p $PID | grep java`
if [ -n "$PID_EXIST" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $PIDS"
PIDS=""

View File

@ -1,10 +0,0 @@
@echo off
setlocal enabledelayedexpansion
set JAVA=java
set OPTS=-XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC
set ENGINE=novel-admin.jar
cd ../
java -jar %OPTS% -Dloader.path=conf,lib %ENGINE%
pause

View File

@ -31,64 +31,9 @@
<build>
<plugins>
<!-- 将相同groupId的依赖模块打包进来 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>${project.groupId}:*:*</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--打包时去除第三方依赖-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
<includes>
<include>
<groupId>non-exists</groupId>
<artifactId>non-exists</artifactId>
</include>
</includes>
</configuration>
</plugin>
<!--拷贝第三方依赖文件到指定目录-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!--target/lib是依赖jar包的输出目录根据自己喜好配置-->
<outputDirectory>target/lib</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
<includeScope>runtime</includeScope>
<excludeGroupIds>${project.groupId}</excludeGroupIds>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
@ -102,32 +47,24 @@
<configuration>
<tasks>
<!-- 文件夹 -->
<copy todir="${project.build.directory}/build/conf" overwrite="true">
<fileset dir="${basedir}/src/main/resources">
<include name="**/*.*"/>
<exclude name="mybatis/*/*.*"/>
</fileset>
<fileset dir="${basedir}/../novel-common/src/main/resources">
<include name="**/*.*"/>
<exclude name="mybatis/**"/>
<copy todir="${project.build.directory}/build/config" overwrite="true">
<fileset dir="${basedir}/src/main/build/config">
<include name="*.*"/>
</fileset>
</copy>
<move todir="${project.build.directory}/build/lib">
<fileset dir="target/lib"/>
</move>
<copy file="${project.build.directory}/${project.artifactId}-${project.version}.jar"
tofile="${project.build.directory}/build/${project.artifactId}.jar" />
tofile="${project.build.directory}/build/${project.artifactId}.jar"/>
<fixcrlf srcdir="${basedir}/src/main/build/scripts" eol="unix"/>
<copy todir="${project.build.directory}/build/bin">
<fileset dir="${basedir}/src/main/build/scripts">
<include name="*.sh" />
<include name="*.txt" />
<include name="*.bat" />
<include name="*.sh"/>
<include name="*.txt"/>
<include name="*.bat"/>
</fileset>
</copy>
<zip destfile='${project.build.directory}/build/${project.artifactId}.zip'>
<zipfileset filemode="755" dir= '${project.build.directory}/build/' />
<zipfileset filemode="755" dir='${project.build.directory}/build/'/>
</zip>
</tasks>
</configuration>

View File

@ -0,0 +1,39 @@
#端口号
server:
port: 8083
#不分表的数据库配置
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
####使用shardingJdbc时
####所有的jdbcType都不能是LONGVARCHAR,否则会导致java.io.NotSerializableException: java.io.StringReader错误
##### 应该替换所有的 LONGVARCHAR 类型为VARCHAR
sharding:
jdbc:
datasource:
ds0:
jdbc-url: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456
#登录用户名密码
admin:
username: admin
password: admin
#
##爬虫自动更新的线程数
##建议小说数量不多或者正在运行新书入库爬虫的情况下设置为1即可
##随着小说数量的增多可以逐渐增加但建议不要超出CPU的线程数
crawl:
update:
thread: 1
#小说内容保存配置
content:
save:
storage: db #存储介质db数据库filetxt文本
path: /Users/xiongxiaoyang/books #txt小说文本保存路径

View File

@ -0,0 +1,94 @@
#!/bin/sh
APP_NAME=novel-crawl
JAR_NAME=$APP_NAME\.jar
#PID 代表是PID文件
PID=$APP_NAME\.pid
#使用说明,用来提示输入参数
usage() {
echo "Usage: ./novel-crawl.sh [start|stop|restart|status]"
exit 1
}
#检查程序是否在运行
is_exist(){
pid=`ps -ef|grep $JAR_NAME|grep -v grep|awk '{print $2}' `
#如果不存在返回1存在返回0
if [ -z "${pid}" ]; then
return 1
else
return 0
fi
}
#启动方法
start(){
is_exist
if [ $? -eq "0" ]; then
echo ">>> 小说精品屋爬虫正在运行 PID = ${pid} <<<"
else
echo ">>> 小说精品屋爬虫开始启动 <<<"
nohup java -jar -Dspring.profiles.active=prod $JAR_NAME >/dev/null 2>&1 &
sleep 10
echo $! > $PID
echo ">>> 小说精品屋爬虫启动完成 PID = $! <<<"
status
fi
}
#停止方法
stop(){
#is_exist
pidf=$(cat $PID)
#echo "$pidf"
echo ">>> 小说精品屋爬虫 PID = $pidf 开始停止 <<<"
kill $pidf
rm -rf $PID
sleep 2
is_exist
if [ $? -eq "0" ]; then
echo ">>> 小说精品屋爬虫 PID = $pid 开始强制停止 <<<"
kill -9 $pid
sleep 2
status
else
status
fi
}
#输出运行状态
status(){
is_exist
if [ $? -eq "0" ]; then
echo ">>> 小说精品屋爬虫正在运行 PID = ${pid} <<<"
else
echo ">>> 小说精品屋爬虫没有运行 <<<"
fi
}
#重启
restart(){
stop
start
}
#根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
"start")
start
;;
"stop")
stop
;;
"status")
status
;;
"restart")
restart
;;
*)
usage
;;
esac
exit 0

View File

@ -1,8 +0,0 @@
1linux启动环境
sh start.sh
3windows启动环境
windows-start.bat
3linux停止应用
sh stop.sh

View File

@ -1,47 +0,0 @@
#!/bin/bash
ENGINE=novel-crawl.jar
cd ../
#部署目路
DEPLOY_DIR=`pwd`
#获取到当前目录的名称
SERVER_NAME=`basename $DEPLOY_DIR`
#应用进程
PIDS=`ps -ef | grep java | grep "$ENGINE" |awk '{print $2}'`
#设置日志文件的输出目录
LOGS_DIR=$DEPLOY_DIR/logs
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
#日志
STDOUT_FILE=$LOGS_DIR/stdout.log
#JAVA 环境配置
JAVA_OPTS=" -Djava.net.preferIPv4Stack=true -Dlog.home=$LOGS_DIR"
JAVA_MEM_OPTS=" -server -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:InitiatingHeapOccupancyPercent=50 -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCDateStamps -verbose:gc -XX:+PrintGCDetails -XX:+PrintHeapAtGC -Xloggc:$LOGS_DIR/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof "
#退出标志
RETVAL="0"
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit $RETVAL
fi
nohup java -jar $JAVA_OPTS $JAVA_MEM_OPTS -Dloader.path=conf,lib $ENGINE > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
if [ $COUNT -gt 0 ]; then
break
fi
done
echo "OK!"
PIDS=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'`
echo "PID: $PIDS"
echo "STDOUT: $STDOUT_FILE"

View File

@ -1,33 +0,0 @@
#!/bin/bash
SERVER_NAME=novel-crawl.jar
#应用进程
PIDS=`ps -ef | grep java | grep "$SERVER_NAME" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in $PIDS ; do
PID_EXIST=`ps -f -p $PID | grep java`
if [ -n "$PID_EXIST" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $PIDS"
PIDS=""

View File

@ -1,10 +0,0 @@
@echo off
setlocal enabledelayedexpansion
set JAVA=java
set OPTS=-XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC
set ENGINE=novel-crawl.jar
cd ../
java -jar %OPTS% -Dloader.path=conf,lib %ENGINE%
pause

View File

@ -70,14 +70,12 @@
</dependency>
<!--引入redisson分布式锁-->
<!-- <dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>${redisson.version}</version>
</dependency>-->
<!-- <dependency>
<groupId>org.redisson</groupId>
<artifactId>redisson-spring-boot-starter</artifactId>
<version>${redisson.version}</version>
</dependency>-->
<dependency>
@ -87,74 +85,11 @@
</dependency>
</dependencies>
<!-- <build>-->
<!-- <plugins>-->
<!-- <plugin>-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </build>-->
<build>
<plugins>
<!-- 将相同groupId的依赖模块打包进来 -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<artifactSet>
<includes>
<include>${project.groupId}:*:*</include>
</includes>
</artifactSet>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<!--打包时去除第三方依赖-->
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layout>ZIP</layout>
<includes>
<include>
<groupId>non-exists</groupId>
<artifactId>non-exists</artifactId>
</include>
</includes>
</configuration>
</plugin>
<!--拷贝第三方依赖文件到指定目录-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<!--target/lib是依赖jar包的输出目录根据自己喜好配置-->
<outputDirectory>target/lib</outputDirectory>
<excludeTransitive>false</excludeTransitive>
<stripVersion>false</stripVersion>
<includeScope>runtime</includeScope>
<excludeGroupIds>${project.groupId}</excludeGroupIds>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
@ -168,32 +103,33 @@
<configuration>
<tasks>
<!-- 文件夹 -->
<copy todir="${project.build.directory}/build/conf" overwrite="true">
<fileset dir="${basedir}/src/main/resources">
<include name="**/*.*"/>
<exclude name="mybatis/*/*.*"/>
<copy todir="${project.build.directory}/build/config" overwrite="true">
<fileset dir="${basedir}/src/main/build/config">
<include name="*.*"/>
</fileset>
<fileset dir="${basedir}/../novel-common/src/main/resources">
<include name="**/*.*"/>
<exclude name="mybatis/**"/>
<fileset dir="${basedir}/src/main/resources">
<include name="application-alipay.yml"/>
<include name="application-website.yml"/>
</fileset>
</copy>
<copy todir="${project.build.directory}/build/templates" overwrite="true">
<fileset dir="${basedir}/../templates">
<include name="**/*.*"/>
</fileset>
</copy>
<move todir="${project.build.directory}/build/lib">
<fileset dir="target/lib"/>
</move>
<copy file="${project.build.directory}/${project.artifactId}-${project.version}.jar"
tofile="${project.build.directory}/build/${project.artifactId}.jar" />
tofile="${project.build.directory}/build/${project.artifactId}.jar"/>
<fixcrlf srcdir="${basedir}/src/main/build/scripts" eol="unix"/>
<copy todir="${project.build.directory}/build/bin">
<fileset dir="${basedir}/src/main/build/scripts">
<include name="*.sh" />
<include name="*.txt" />
<include name="*.bat" />
<include name="*.sh"/>
<include name="*.txt"/>
<include name="*.bat"/>
</fileset>
</copy>
<zip destfile='${project.build.directory}/build/${project.artifactId}.zip'>
<zipfileset filemode="755" dir= '${project.build.directory}/build/' />
<zipfileset filemode="755" dir='${project.build.directory}/build/'/>
</zip>
</tasks>
</configuration>
@ -202,5 +138,112 @@
</plugin>
</plugins>
</build>
<!-- <build>-->
<!-- <plugins>-->
<!-- &lt;!&ndash; 将相同groupId的依赖模块打包进来 &ndash;&gt;-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-shade-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <createDependencyReducedPom>false</createDependencyReducedPom>-->
<!-- </configuration>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>shade</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <artifactSet>-->
<!-- <includes>-->
<!-- <include>${project.groupId}:*:*</include>-->
<!-- </includes>-->
<!-- </artifactSet>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- &lt;!&ndash;打包时去除第三方依赖&ndash;&gt;-->
<!-- <groupId>org.springframework.boot</groupId>-->
<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
<!-- <configuration>-->
<!-- <layout>ZIP</layout>-->
<!-- <includes>-->
<!-- <include>-->
<!-- <groupId>non-exists</groupId>-->
<!-- <artifactId>non-exists</artifactId>-->
<!-- </include>-->
<!-- </includes>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- &lt;!&ndash;拷贝第三方依赖文件到指定目录&ndash;&gt;-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-dependency-plugin</artifactId>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>copy-dependencies</id>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>copy-dependencies</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- &lt;!&ndash;target/lib是依赖jar包的输出目录根据自己喜好配置&ndash;&gt;-->
<!-- <outputDirectory>target/lib</outputDirectory>-->
<!-- <excludeTransitive>false</excludeTransitive>-->
<!-- <stripVersion>false</stripVersion>-->
<!-- <includeScope>runtime</includeScope>-->
<!-- <excludeGroupIds>${project.groupId}</excludeGroupIds>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <artifactId>maven-antrun-plugin</artifactId>-->
<!-- <version>1.8</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>run</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <tasks>-->
<!-- &lt;!&ndash; 文件夹 &ndash;&gt;-->
<!-- <copy todir="${project.build.directory}/build/conf" overwrite="true">-->
<!-- <fileset dir="${basedir}/src/main/resources">-->
<!-- <include name="**/*.*"/>-->
<!-- <exclude name="mybatis/*/*.*"/>-->
<!-- </fileset>-->
<!-- <fileset dir="${basedir}/../novel-common/src/main/resources">-->
<!-- <include name="**/*.*"/>-->
<!-- <exclude name="mybatis/**"/>-->
<!-- </fileset>-->
<!-- </copy>-->
<!-- <move todir="${project.build.directory}/build/lib">-->
<!-- <fileset dir="target/lib"/>-->
<!-- </move>-->
<!-- <copy file="${project.build.directory}/${project.artifactId}-${project.version}.jar"-->
<!-- tofile="${project.build.directory}/build/${project.artifactId}.jar" />-->
<!-- <fixcrlf srcdir="${basedir}/src/main/build/scripts" eol="unix"/>-->
<!-- <copy todir="${project.build.directory}/build/bin">-->
<!-- <fileset dir="${basedir}/src/main/build/scripts">-->
<!-- <include name="*.sh" />-->
<!-- <include name="*.txt" />-->
<!-- <include name="*.bat" />-->
<!-- </fileset>-->
<!-- </copy>-->
<!-- <zip destfile='${project.build.directory}/build/${project.artifactId}.zip'>-->
<!-- <zipfileset filemode="755" dir= '${project.build.directory}/build/' />-->
<!-- </zip>-->
<!-- </tasks>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
<!-- </plugins>-->
<!-- </build>-->
</project>

View File

@ -0,0 +1,45 @@
#端口号
server:
port: 8085
#不分表的数据库配置
spring:
datasource:
url: jdbc:mysql://127.0.0.1:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: root
####使用shardingJdbc时
####所有的jdbcType都不能是LONGVARCHAR,否则会导致java.io.NotSerializableException: java.io.StringReader错误
##### 应该替换所有的 LONGVARCHAR 类型为VARCHAR
sharding:
jdbc:
datasource:
ds0:
jdbc-url: jdbc:mysql://localhost:3306/novel_plus?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
username: root
password: test123456
pic:
save:
#图片保存方式, 1不保存使用网络图片 2本地保存
type: 2
#图片保存路径
path: /var/pic
#模版配置
templates:
name: orange
#小说内容保存配置
content:
save:
storage: db #存储介质db数据库filetxt文本
path: /Users/xiongxiaoyang/books #txt小说文本保存路径

View File

@ -0,0 +1,94 @@
#!/bin/sh
APP_NAME=novel-front
JAR_NAME=$APP_NAME\.jar
#PID 代表是PID文件
PID=$APP_NAME\.pid
#使用说明,用来提示输入参数
usage() {
echo "Usage: ./novel-front.sh [start|stop|restart|status]"
exit 1
}
#检查程序是否在运行
is_exist(){
pid=`ps -ef|grep $JAR_NAME|grep -v grep|awk '{print $2}' `
#如果不存在返回1存在返回0
if [ -z "${pid}" ]; then
return 1
else
return 0
fi
}
#启动方法
start(){
is_exist
if [ $? -eq "0" ]; then
echo ">>> 小说精品屋前台正在运行 PID = ${pid} <<<"
else
echo ">>> 小说精品屋前台开始启动 <<<"
nohup java -jar -Dspring.profiles.active=prod $JAR_NAME >/dev/null 2>&1 &
sleep 20
echo $! > $PID
echo ">>> 小说精品屋前台启动完成 PID = $! <<<"
status
fi
}
#停止方法
stop(){
#is_exist
pidf=$(cat $PID)
#echo "$pidf"
echo ">>> 小说精品屋前台 PID = $pidf 开始停止 <<<"
kill $pidf
rm -rf $PID
sleep 2
is_exist
if [ $? -eq "0" ]; then
echo ">>> 小说精品屋前台 PID = $pid 开始强制停止 <<<"
kill -9 $pid
sleep 2
status
else
status
fi
}
#输出运行状态
status(){
is_exist
if [ $? -eq "0" ]; then
echo ">>> 小说精品屋前台正在运行 PID = ${pid} <<<"
else
echo ">>> 小说精品屋前台没有运行 <<<"
fi
}
#重启
restart(){
stop
start
}
#根据输入参数,选择执行对应方法,不输入则执行使用说明
case "$1" in
"start")
start
;;
"stop")
stop
;;
"status")
status
;;
"restart")
restart
;;
*)
usage
;;
esac
exit 0

View File

@ -1,8 +0,0 @@
1linux启动环境
sh start.sh
3windows启动环境
windows-start.bat
3linux停止应用
sh stop.sh

View File

@ -1,47 +0,0 @@
#!/bin/bash
ENGINE=novel-front.jar
cd ../
#部署目路
DEPLOY_DIR=`pwd`
#获取到当前目录的名称
SERVER_NAME=`basename $DEPLOY_DIR`
#应用进程
PIDS=`ps -ef | grep java | grep "$ENGINE" |awk '{print $2}'`
#设置日志文件的输出目录
LOGS_DIR=$DEPLOY_DIR/logs
if [ ! -d $LOGS_DIR ]; then
mkdir $LOGS_DIR
fi
#日志
STDOUT_FILE=$LOGS_DIR/stdout.log
#JAVA 环境配置
JAVA_OPTS=" -Djava.net.preferIPv4Stack=true -Dlog.home=$LOGS_DIR"
JAVA_MEM_OPTS=" -server -XX:+UseG1GC -XX:MaxGCPauseMillis=100 -XX:InitiatingHeapOccupancyPercent=50 -XX:+PrintGCApplicationStoppedTime -XX:+PrintGCApplicationConcurrentTime -XX:+PrintGCDateStamps -verbose:gc -XX:+PrintGCDetails -XX:+PrintHeapAtGC -Xloggc:$LOGS_DIR/gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=dump.hprof "
#退出标志
RETVAL="0"
if [ -n "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME already started!"
echo "PID: $PIDS"
exit $RETVAL
fi
nohup java -jar $JAVA_OPTS $JAVA_MEM_OPTS -Dloader.path=conf,lib $ENGINE > $STDOUT_FILE 2>&1 &
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}' | wc -l`
if [ $COUNT -gt 0 ]; then
break
fi
done
echo "OK!"
PIDS=`ps -f | grep java | grep "$DEPLOY_DIR" | awk '{print $2}'`
echo "PID: $PIDS"
echo "STDOUT: $STDOUT_FILE"

View File

@ -1,33 +0,0 @@
#!/bin/bash
SERVER_NAME=novel-front.jar
#应用进程
PIDS=`ps -ef | grep java | grep "$SERVER_NAME" |awk '{print $2}'`
if [ -z "$PIDS" ]; then
echo "ERROR: The $SERVER_NAME does not started!"
exit 1
fi
echo -e "Stopping the $SERVER_NAME ...\c"
for PID in $PIDS ; do
kill $PID > /dev/null 2>&1
done
COUNT=0
while [ $COUNT -lt 1 ]; do
echo -e ".\c"
sleep 1
COUNT=1
for PID in $PIDS ; do
PID_EXIST=`ps -f -p $PID | grep java`
if [ -n "$PID_EXIST" ]; then
COUNT=0
break
fi
done
done
echo "OK!"
echo "PID: $PIDS"
PIDS=""

View File

@ -1,10 +0,0 @@
@echo off
setlocal enabledelayedexpansion
set JAVA=java
set OPTS=-XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=128m -Xms1024m -Xmx1024m -Xmn256m -Xss256k -XX:SurvivorRatio=8 -XX:+UseConcMarkSweepGC
set ENGINE=novel-front.jar
cd ../
java -jar %OPTS% -Dloader.path=conf,lib %ENGINE%
pause