Prechádzať zdrojové kódy

修改打包方式为打包为zip形式

qiubo 3 rokov pred
rodič
commit
8c0e2e0caf

+ 13 - 0
deploy/bin/shutdown.bat

@@ -0,0 +1,13 @@
+@echo off
+
+if not exist "%JAVA_HOME%\bin\jps.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better! & EXIT /B 1
+
+setlocal
+
+set "PATH=%JAVA_HOME%\bin;%PATH%"
+
+echo killing bankclear
+
+for /f "tokens=1" %%i in ('jps -m ^| find "cbm-web"') do ( taskkill /F /PID %%i )
+
+echo Done!

+ 16 - 0
deploy/bin/shutdown.sh

@@ -0,0 +1,16 @@
+#!/bin/sh
+
+cd `dirname $0`/../target
+target_dir=`pwd`
+
+pid=`ps ax | grep -i 'bankclear' | grep ${target_dir} | grep java | grep -v grep | awk '{print $1}'`
+if [ -z "$pid" ] ; then
+        echo "No pd running.."
+        exit 0;
+fi
+
+echo "The pd(${pid}) is running..."
+
+kill ${pid}
+
+echo "Send shutdown request to pd(${pid}) OK"

+ 30 - 0
deploy/bin/startup.bat

@@ -0,0 +1,30 @@
+@echo off
+
+if not exist "%JAVA_HOME%\bin\java.exe" echo Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better! & EXIT /B 1
+set "JAVA=%JAVA_HOME%\bin\java.exe"
+
+setlocal enabledelayedexpansion
+
+set BASE_DIR=%~dp0
+rem added double quotation marks to avoid the issue caused by the folder names containing spaces.
+rem removed the last 5 chars(which means \bin\) to get the base DIR.
+set BASE_DIR="%BASE_DIR:~0,-5%"
+
+set DEFAULT_SEARCH_LOCATIONS="classpath:/,classpath:/config/,file:./,file:./config/"
+set CUSTOM_SEARCH_LOCATIONS=%DEFAULT_SEARCH_LOCATIONS%,file:%BASE_DIR%/conf/
+
+
+set SERVER=bankclear
+
+
+set "JAVA_OPT=%JAVA_OPT% -Xms1024m -Xmx1024m -Xmn512m"
+
+
+set "JAVA_OPT=%JAVA_OPT% -Dsystem.basedir=%BASE_DIR%"
+set "JAVA_OPT=%JAVA_OPT% -Dloader.path=%BASE_DIR%/plugins/health -jar %BASE_DIR%\target\%SERVER%.jar"
+set "JAVA_OPT=%JAVA_OPT% --spring.config.location=%CUSTOM_SEARCH_LOCATIONS%"
+set "JAVA_OPT=%JAVA_OPT% --logging.config=%BASE_DIR%/conf/log4j2.xml"
+
+call "%JAVA%" %JAVA_OPT% bankclear %*
+
+pause

+ 52 - 0
deploy/bin/startup.sh

@@ -0,0 +1,52 @@
+#!/bin/sh
+
+error_exit ()
+{
+    echo "ERROR: $1 !!"
+    exit 1
+}
+[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=$HOME/jdk/java
+[ ! -e "$JAVA_HOME/bin/java" ] && JAVA_HOME=/usr/java
+[ ! -e "$JAVA_HOME/bin/java" ] && unset JAVA_HOME
+
+
+if [ -z "$JAVA_HOME" ]; then
+      error_exit "Please set the JAVA_HOME variable in your environment, We need java(x64)! jdk8 or later is better!"
+fi
+
+
+export SERVER="bankclear"
+
+export JAVA_HOME
+export JAVA="$JAVA_HOME/bin/java"
+export BASE_DIR=`cd $(dirname $0)/..; pwd`
+export DEFAULT_SEARCH_LOCATIONS="classpath:/,classpath:/config/,file:./,file:./config/"
+export CUSTOM_SEARCH_LOCATIONS=${DEFAULT_SEARCH_LOCATIONS},file:${BASE_DIR}/conf/
+
+#===========================================================================================
+# JVM Configuration
+#===========================================================================================
+JAVA_OPT="${JAVA_OPT} -Xms1024m -Xmx1024m -Xmn512m"
+#JAVA_OPT="${JAVA_OPT} -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
+JAVA_OPT="${JAVA_OPT} -Djava.ext.dirs=${JAVA_HOME}/jre/lib/ext:${JAVA_HOME}/lib/ext:${BASE_DIR}/plugins/cmdb:${BASE_DIR}/plugins/mysql"
+
+
+JAVA_OPT="${JAVA_OPT} -Dsystem.basedir=${BASE_DIR}"
+JAVA_OPT="${JAVA_OPT} -Dloader.path=${BASE_DIR}/plugins/health -jar ${BASE_DIR}/target/${SERVER}.jar"
+JAVA_OPT="${JAVA_OPT} ${JAVA_OPT_EXT}"
+JAVA_OPT="${JAVA_OPT} --spring.config.location=${CUSTOM_SEARCH_LOCATIONS}"
+JAVA_OPT="${JAVA_OPT} --logging.config=${BASE_DIR}/conf/log4j2.xml"
+JAVA_OPT="${JAVA_OPT} --server.max-http-header-size=524288"
+
+if [ ! -d "${BASE_DIR}/logs" ]; then
+  mkdir ${BASE_DIR}/logs
+fi
+
+echo "$JAVA ${JAVA_OPT}"
+
+
+echo "cbm is starting ..."
+
+
+nohup $JAVA ${JAVA_OPT} pd >> /dev/null 2>&1 &
+echo "cbm is starting,you can check the ${BASE_DIR}/logs/default.log"

+ 52 - 35
pom.xml

@@ -26,11 +26,11 @@
 
 	<dependencies>
 		<dependency>
-			<groupId>log4j</groupId>
-			<artifactId>log4j</artifactId>
-			<version>1.2.17</version>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-starter-log4j2</artifactId>
 		</dependency>
 
+
 		<dependency>
 			<groupId>org.apache.camel</groupId>
 			<artifactId>camel-ftp</artifactId>
@@ -45,6 +45,13 @@
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
 			<artifactId>spring-boot-starter-web</artifactId>
+			<exclusions>
+				<!-- 排除掉logging,不使用logback,改用log4j2 -->
+				<exclusion>
+					<groupId>org.springframework.boot</groupId>
+					<artifactId>spring-boot-starter-logging</artifactId>
+				</exclusion>
+			</exclusions>
 		</dependency>
 		<dependency>
 			<groupId>org.springframework.boot</groupId>
@@ -122,53 +129,63 @@
 		</dependency>
 	</dependencies>
 
+
 	<build>
+		<resources>
+			<resource>
+				<directory>src/main/java</directory>
+				<includes>
+					<include>**/*.xml</include>
+				</includes>
+				<filtering>false</filtering>
+			</resource>
+			<resource>
+				<directory>src/main/resources</directory>
+				<excludes>
+					<exclude>*.sh</exclude>
+				</excludes>
+				<filtering>false</filtering>
+			</resource>
+		</resources>
+
 		<plugins>
-			<plugin>
-				<groupId>org.springframework.boot</groupId>
-				<artifactId>spring-boot-maven-plugin</artifactId>
-			</plugin>
 			<plugin>
 				<groupId>org.apache.maven.plugins</groupId>
-				<artifactId>maven-surefire-plugin</artifactId>
-				<version>2.18.1</version>
+				<artifactId>maven-compiler-plugin</artifactId>
 				<configuration>
-					<skipTests>true</skipTests>
+					<source>1.8</source>
+					<target>1.8</target>
+					<encoding>utf-8</encoding>
 				</configuration>
 			</plugin>
-			<!-- mybatis generator-->
 			<plugin>
-				<groupId>org.mybatis.generator</groupId>
-				<artifactId>mybatis-generator-maven-plugin</artifactId>
-				<version>1.3.5</version>
-				<dependencies>
-					<dependency>
-						<groupId> mysql</groupId>
-						<artifactId> mysql-connector-java</artifactId>
-						<version>5.1.39</version>
-					</dependency>
-					<dependency>
-						<groupId>org.mybatis.generator</groupId>
-						<artifactId>mybatis-generator-core</artifactId>
-						<version>1.3.5</version>
-					</dependency>
-				</dependencies>
+				<groupId>org.springframework.boot</groupId>
+				<artifactId>spring-boot-maven-plugin</artifactId>
+			</plugin>
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-assembly-plugin</artifactId>
 				<executions>
 					<execution>
-						<id>Generate MyBatis Artifacts</id>
-						<phase>deploy</phase>
+						<id>assembly</id>
+						<phase>package</phase>
 						<goals>
-							<goal>generate</goal>
+							<goal>single</goal>
 						</goals>
+						<configuration>
+							<descriptors>
+								<descriptor>src/main/assembly/assembly.xml</descriptor>
+							</descriptors>
+						</configuration>
 					</execution>
 				</executions>
+			</plugin>
+
+			<plugin>
+				<groupId>org.apache.maven.plugins</groupId>
+				<artifactId>maven-surefire-plugin</artifactId>
 				<configuration>
-					<!--允许移动生成的文件 -->
-					<verbose>true</verbose>
-					<!-- 是否覆盖 -->
-					<overwrite>true</overwrite>
-					<!-- 自动生成的配置 -->
-					<configurationFile>src/main/resources/generatorConfig.xml</configurationFile>
+					<skip>true</skip>
 				</configuration>
 			</plugin>
 		</plugins>

+ 61 - 0
src/main/assembly/assembly.xml

@@ -0,0 +1,61 @@
+<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
+          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+          xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
+    <id>bin</id>
+    <formats>
+        <format>tar.gz</format>
+    </formats>
+    <includeBaseDirectory>true</includeBaseDirectory>
+
+    <files>
+        <file>
+            <fileMode>775</fileMode>
+            <source>target/${project.build.finalName}.jar</source>
+            <destName>bankclear.jar</destName>
+            <outputDirectory>./target</outputDirectory>
+        </file>
+    </files>
+
+    <fileSets>
+        <fileSet>
+            <directory>src/main/resources</directory>
+            <outputDirectory>./conf</outputDirectory>
+            <includes>
+                <include>application.properties</include>
+                <include>application-dev.properties</include>
+                <include>application-pro.properties</include>
+                <include>application-test.properties</include>
+                <include>generatorConfig.xml</include>
+                <include>log4j.properties</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>src/main/resources/logconf</directory>
+            <outputDirectory>./conf</outputDirectory>
+            <includes>
+                <include>log4j2.xml</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>src/main/resources/i18n</directory>
+            <outputDirectory>./i18n</outputDirectory>
+            <includes>
+                <include>*.properties</include>
+            </includes>
+        </fileSet>
+        <fileSet>
+            <directory>src/main/resources/conf/excel</directory>
+            <outputDirectory>./conf/excel</outputDirectory>
+        </fileSet>
+
+        <fileSet>
+            <fileMode>775</fileMode>
+            <directory>deploy/bin</directory>
+            <outputDirectory>./bin</outputDirectory>
+        </fileSet>
+        <fileSet>
+            <directory>deploy/db</directory>
+            <outputDirectory>./db</outputDirectory>
+        </fileSet>
+    </fileSets>
+</assembly>

+ 81 - 0
src/main/resources/logconf/log4j2.xml

@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="WARN">
+    <Properties>
+        <!-- 将系统属性进行一次本地转换 -->
+        <Property name="LOGGING_PATH">${sys:system.basedir}/logs</Property>
+        <Property name="LOGGING_FILE_ENCODING">UTF-8</Property>
+
+        <Property name="PID">????</Property>
+        <Property name="LOG_EXCEPTION_CONVERSION_WORD">%xwEx</Property>
+        <Property name="LOG_LEVEL_PATTERN">%5p</Property>
+        <Property name="LOG_DATEFORMAT_PATTERN">yyyy-MM-dd HH:mm:ss.SSS</Property>
+        <Property name="CONSOLE_LOG_PATTERN">%clr{%d{${LOG_DATEFORMAT_PATTERN}}}{faint} %clr{${LOG_LEVEL_PATTERN}} %clr{${sys:PID}}{magenta} %clr{---}{faint} %clr{[%15.15t]}{faint} %clr{%-40.40c{1.}}{cyan} %clr{:}{faint} %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
+        <Property name="FILE_LOG_PATTERN">%d{${LOG_DATEFORMAT_PATTERN}} ${LOG_LEVEL_PATTERN} ${sys:PID} --- [%t] %-40.40c{1.} : %m%n${sys:LOG_EXCEPTION_CONVERSION_WORD}</Property>
+    </Properties>
+
+    <Appenders>
+        <Console name="Console" target="SYSTEM_OUT">
+            <PatternLayout pattern="${sys:CONSOLE_LOG_PATTERN}" />
+        </Console>
+        <RollingFile name="default-appender"
+                     fileName="${LOGGING_PATH}/default.log"
+                     filePattern="${LOGGING_PATH}/default.%d{yyyy-MM-dd}.log"
+                     append="true">
+            <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY" />
+            <PatternLayout pattern="${sys:FILE_LOG_PATTERN}" />
+            <Policies>
+                <!-- 按天分日志文件:重要的是 filePattern 配置到按照天 -->
+                <TimeBasedTriggeringPolicy interval="1" modulate="true" />
+                <SizeBasedTriggeringPolicy size="10 MB" />
+            </Policies>
+            <!-- 超过30个文件时,删除旧文件  -->
+            <DefaultRolloverStrategy max="30" />
+        </RollingFile>
+        <RollingFile name="sys-error-appender"
+                     fileName="${LOGGING_PATH}/sys-error.log"
+                     filePattern="${LOGGING_PATH}/sys-error.%d{yyyy-MM-dd}.log"
+                     append="true">
+            <!-- only print error log -->
+            <ThresholdFilter level="error" onMatch="ACCEPT" onMismatch="DENY" />
+            <PatternLayout pattern="${sys:FILE_LOG_PATTERN}" />
+            <Policies>
+                <!-- 按天分日志文件:重要的是 filePattern 配置到按照天 -->
+                <TimeBasedTriggeringPolicy interval="1" modulate="true" />
+                <SizeBasedTriggeringPolicy size="10 MB" />
+            </Policies>
+            <!-- 超过30个文件时,删除旧文件  -->
+            <DefaultRolloverStrategy max="30" />
+        </RollingFile>
+        <RollingFile name="sys-rest-appender"
+                     fileName="${LOGGING_PATH}/sys-rest.log"
+                     filePattern="${LOGGING_PATH}/sys-rest.%d{yyyy-MM-dd}.log"
+                     append="true">
+            <!-- only print error log -->
+            <ThresholdFilter level="debug" onMatch="ACCEPT" onMismatch="DENY" />
+            <PatternLayout pattern="${sys:FILE_LOG_PATTERN}" />
+            <Policies>
+                <!-- 按天分日志文件:重要的是 filePattern 配置到按照天 -->
+                <TimeBasedTriggeringPolicy interval="1" modulate="true" />
+                <SizeBasedTriggeringPolicy size="10 MB" />
+            </Policies>
+            <!-- 超过30个文件时,删除旧文件  -->
+            <DefaultRolloverStrategy max="30" />
+        </RollingFile>
+    </Appenders>
+    <Loggers>
+        <Logger name="com.hywa.banktest" level="debug" additivity="false">
+            <AppenderRef ref="Console" />
+            <AppenderRef ref="default-appender" />
+            <AppenderRef ref="sys-error-appender" />
+        </Logger>
+        <Logger name="sys-rest" level="debug" additivity="false">
+            <AppenderRef ref="Console" />
+            <AppenderRef ref="sys-rest-appender" />
+        </Logger>
+        <Root level="info">
+            <AppenderRef ref="Console" />
+            <AppenderRef ref="default-appender" />
+            <AppenderRef ref="sys-error-appender" />
+        </Root>
+    </Loggers>
+</Configuration>