正在显示
17 个修改的文件
包含
1576 行增加
和
0 行删除
.gitignore
0 → 100644
1 | +/target/ | ||
2 | +!.mvn/wrapper/maven-wrapper.jar | ||
3 | + | ||
4 | +### STS ### | ||
5 | +.apt_generated | ||
6 | +.classpath | ||
7 | +.factorypath | ||
8 | +.project | ||
9 | +.settings | ||
10 | +.springBeans | ||
11 | +.sts4-cache | ||
12 | + | ||
13 | +### IntelliJ IDEA ### | ||
14 | +.idea | ||
15 | +*.iws | ||
16 | +*.iml | ||
17 | +*.ipr | ||
18 | + | ||
19 | +### NetBeans ### | ||
20 | +/nbproject/private/ | ||
21 | +/build/ | ||
22 | +/nbbuild/ | ||
23 | +/dist/ | ||
24 | +/nbdist/ | ||
25 | +/.nb-gradle/ |
mvnw
0 → 100755
1 | +#!/bin/sh | ||
2 | +# ---------------------------------------------------------------------------- | ||
3 | +# Licensed to the Apache Software Foundation (ASF) under one | ||
4 | +# or more contributor license agreements. See the NOTICE file | ||
5 | +# distributed with this work for additional information | ||
6 | +# regarding copyright ownership. The ASF licenses this file | ||
7 | +# to you under the Apache License, Version 2.0 (the | ||
8 | +# "License"); you may not use this file except in compliance | ||
9 | +# with the License. You may obtain a copy of the License at | ||
10 | +# | ||
11 | +# http://www.apache.org/licenses/LICENSE-2.0 | ||
12 | +# | ||
13 | +# Unless required by applicable law or agreed to in writing, | ||
14 | +# software distributed under the License is distributed on an | ||
15 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
16 | +# KIND, either express or implied. See the License for the | ||
17 | +# specific language governing permissions and limitations | ||
18 | +# under the License. | ||
19 | +# ---------------------------------------------------------------------------- | ||
20 | + | ||
21 | +# ---------------------------------------------------------------------------- | ||
22 | +# Maven2 Start Up Batch script | ||
23 | +# | ||
24 | +# Required ENV vars: | ||
25 | +# ------------------ | ||
26 | +# JAVA_HOME - location of a JDK home dir | ||
27 | +# | ||
28 | +# Optional ENV vars | ||
29 | +# ----------------- | ||
30 | +# M2_HOME - location of maven2's installed home dir | ||
31 | +# MAVEN_OPTS - parameters passed to the Java VM when running Maven | ||
32 | +# e.g. to debug Maven itself, use | ||
33 | +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 | ||
34 | +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files | ||
35 | +# ---------------------------------------------------------------------------- | ||
36 | + | ||
37 | +if [ -z "$MAVEN_SKIP_RC" ] ; then | ||
38 | + | ||
39 | + if [ -f /etc/mavenrc ] ; then | ||
40 | + . /etc/mavenrc | ||
41 | + fi | ||
42 | + | ||
43 | + if [ -f "$HOME/.mavenrc" ] ; then | ||
44 | + . "$HOME/.mavenrc" | ||
45 | + fi | ||
46 | + | ||
47 | +fi | ||
48 | + | ||
49 | +# OS specific support. $var _must_ be set to either true or false. | ||
50 | +cygwin=false; | ||
51 | +darwin=false; | ||
52 | +mingw=false | ||
53 | +case "`uname`" in | ||
54 | + CYGWIN*) cygwin=true ;; | ||
55 | + MINGW*) mingw=true;; | ||
56 | + Darwin*) darwin=true | ||
57 | + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home | ||
58 | + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html | ||
59 | + if [ -z "$JAVA_HOME" ]; then | ||
60 | + if [ -x "/usr/libexec/java_home" ]; then | ||
61 | + export JAVA_HOME="`/usr/libexec/java_home`" | ||
62 | + else | ||
63 | + export JAVA_HOME="/Library/Java/Home" | ||
64 | + fi | ||
65 | + fi | ||
66 | + ;; | ||
67 | +esac | ||
68 | + | ||
69 | +if [ -z "$JAVA_HOME" ] ; then | ||
70 | + if [ -r /etc/gentoo-release ] ; then | ||
71 | + JAVA_HOME=`java-config --jre-home` | ||
72 | + fi | ||
73 | +fi | ||
74 | + | ||
75 | +if [ -z "$M2_HOME" ] ; then | ||
76 | + ## resolve links - $0 may be a link to maven's home | ||
77 | + PRG="$0" | ||
78 | + | ||
79 | + # need this for relative symlinks | ||
80 | + while [ -h "$PRG" ] ; do | ||
81 | + ls=`ls -ld "$PRG"` | ||
82 | + link=`expr "$ls" : '.*-> \(.*\)$'` | ||
83 | + if expr "$link" : '/.*' > /dev/null; then | ||
84 | + PRG="$link" | ||
85 | + else | ||
86 | + PRG="`dirname "$PRG"`/$link" | ||
87 | + fi | ||
88 | + done | ||
89 | + | ||
90 | + saveddir=`pwd` | ||
91 | + | ||
92 | + M2_HOME=`dirname "$PRG"`/.. | ||
93 | + | ||
94 | + # make it fully qualified | ||
95 | + M2_HOME=`cd "$M2_HOME" && pwd` | ||
96 | + | ||
97 | + cd "$saveddir" | ||
98 | + # echo Using m2 at $M2_HOME | ||
99 | +fi | ||
100 | + | ||
101 | +# For Cygwin, ensure paths are in UNIX format before anything is touched | ||
102 | +if $cygwin ; then | ||
103 | + [ -n "$M2_HOME" ] && | ||
104 | + M2_HOME=`cygpath --unix "$M2_HOME"` | ||
105 | + [ -n "$JAVA_HOME" ] && | ||
106 | + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` | ||
107 | + [ -n "$CLASSPATH" ] && | ||
108 | + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` | ||
109 | +fi | ||
110 | + | ||
111 | +# For Mingw, ensure paths are in UNIX format before anything is touched | ||
112 | +if $mingw ; then | ||
113 | + [ -n "$M2_HOME" ] && | ||
114 | + M2_HOME="`(cd "$M2_HOME"; pwd)`" | ||
115 | + [ -n "$JAVA_HOME" ] && | ||
116 | + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" | ||
117 | + # TODO classpath? | ||
118 | +fi | ||
119 | + | ||
120 | +if [ -z "$JAVA_HOME" ]; then | ||
121 | + javaExecutable="`which javac`" | ||
122 | + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then | ||
123 | + # readlink(1) is not available as standard on Solaris 10. | ||
124 | + readLink=`which readlink` | ||
125 | + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then | ||
126 | + if $darwin ; then | ||
127 | + javaHome="`dirname \"$javaExecutable\"`" | ||
128 | + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" | ||
129 | + else | ||
130 | + javaExecutable="`readlink -f \"$javaExecutable\"`" | ||
131 | + fi | ||
132 | + javaHome="`dirname \"$javaExecutable\"`" | ||
133 | + javaHome=`expr "$javaHome" : '\(.*\)/bin'` | ||
134 | + JAVA_HOME="$javaHome" | ||
135 | + export JAVA_HOME | ||
136 | + fi | ||
137 | + fi | ||
138 | +fi | ||
139 | + | ||
140 | +if [ -z "$JAVACMD" ] ; then | ||
141 | + if [ -n "$JAVA_HOME" ] ; then | ||
142 | + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then | ||
143 | + # IBM's JDK on AIX uses strange locations for the executables | ||
144 | + JAVACMD="$JAVA_HOME/jre/sh/java" | ||
145 | + else | ||
146 | + JAVACMD="$JAVA_HOME/bin/java" | ||
147 | + fi | ||
148 | + else | ||
149 | + JAVACMD="`which java`" | ||
150 | + fi | ||
151 | +fi | ||
152 | + | ||
153 | +if [ ! -x "$JAVACMD" ] ; then | ||
154 | + echo "Error: JAVA_HOME is not defined correctly." >&2 | ||
155 | + echo " We cannot execute $JAVACMD" >&2 | ||
156 | + exit 1 | ||
157 | +fi | ||
158 | + | ||
159 | +if [ -z "$JAVA_HOME" ] ; then | ||
160 | + echo "Warning: JAVA_HOME environment variable is not set." | ||
161 | +fi | ||
162 | + | ||
163 | +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher | ||
164 | + | ||
165 | +# traverses directory structure from process work directory to filesystem root | ||
166 | +# first directory with .mvn subdirectory is considered project base directory | ||
167 | +find_maven_basedir() { | ||
168 | + | ||
169 | + if [ -z "$1" ] | ||
170 | + then | ||
171 | + echo "Path not specified to find_maven_basedir" | ||
172 | + return 1 | ||
173 | + fi | ||
174 | + | ||
175 | + basedir="$1" | ||
176 | + wdir="$1" | ||
177 | + while [ "$wdir" != '/' ] ; do | ||
178 | + if [ -d "$wdir"/.mvn ] ; then | ||
179 | + basedir=$wdir | ||
180 | + break | ||
181 | + fi | ||
182 | + # workaround for JBEAP-8937 (on Solaris 10/Sparc) | ||
183 | + if [ -d "${wdir}" ]; then | ||
184 | + wdir=`cd "$wdir/.."; pwd` | ||
185 | + fi | ||
186 | + # end of workaround | ||
187 | + done | ||
188 | + echo "${basedir}" | ||
189 | +} | ||
190 | + | ||
191 | +# concatenates all lines of a file | ||
192 | +concat_lines() { | ||
193 | + if [ -f "$1" ]; then | ||
194 | + echo "$(tr -s '\n' ' ' < "$1")" | ||
195 | + fi | ||
196 | +} | ||
197 | + | ||
198 | +BASE_DIR=`find_maven_basedir "$(pwd)"` | ||
199 | +if [ -z "$BASE_DIR" ]; then | ||
200 | + exit 1; | ||
201 | +fi | ||
202 | + | ||
203 | +########################################################################################## | ||
204 | +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central | ||
205 | +# This allows using the maven wrapper in projects that prohibit checking in binary data. | ||
206 | +########################################################################################## | ||
207 | +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then | ||
208 | + if [ "$MVNW_VERBOSE" = true ]; then | ||
209 | + echo "Found .mvn/wrapper/maven-wrapper.jar" | ||
210 | + fi | ||
211 | +else | ||
212 | + if [ "$MVNW_VERBOSE" = true ]; then | ||
213 | + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." | ||
214 | + fi | ||
215 | + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" | ||
216 | + while IFS="=" read key value; do | ||
217 | + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; | ||
218 | + esac | ||
219 | + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" | ||
220 | + if [ "$MVNW_VERBOSE" = true ]; then | ||
221 | + echo "Downloading from: $jarUrl" | ||
222 | + fi | ||
223 | + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" | ||
224 | + | ||
225 | + if command -v wget > /dev/null; then | ||
226 | + if [ "$MVNW_VERBOSE" = true ]; then | ||
227 | + echo "Found wget ... using wget" | ||
228 | + fi | ||
229 | + wget "$jarUrl" -O "$wrapperJarPath" | ||
230 | + elif command -v curl > /dev/null; then | ||
231 | + if [ "$MVNW_VERBOSE" = true ]; then | ||
232 | + echo "Found curl ... using curl" | ||
233 | + fi | ||
234 | + curl -o "$wrapperJarPath" "$jarUrl" | ||
235 | + else | ||
236 | + if [ "$MVNW_VERBOSE" = true ]; then | ||
237 | + echo "Falling back to using Java to download" | ||
238 | + fi | ||
239 | + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" | ||
240 | + if [ -e "$javaClass" ]; then | ||
241 | + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then | ||
242 | + if [ "$MVNW_VERBOSE" = true ]; then | ||
243 | + echo " - Compiling MavenWrapperDownloader.java ..." | ||
244 | + fi | ||
245 | + # Compiling the Java class | ||
246 | + ("$JAVA_HOME/bin/javac" "$javaClass") | ||
247 | + fi | ||
248 | + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then | ||
249 | + # Running the downloader | ||
250 | + if [ "$MVNW_VERBOSE" = true ]; then | ||
251 | + echo " - Running MavenWrapperDownloader.java ..." | ||
252 | + fi | ||
253 | + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") | ||
254 | + fi | ||
255 | + fi | ||
256 | + fi | ||
257 | +fi | ||
258 | +########################################################################################## | ||
259 | +# End of extension | ||
260 | +########################################################################################## | ||
261 | + | ||
262 | +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} | ||
263 | +if [ "$MVNW_VERBOSE" = true ]; then | ||
264 | + echo $MAVEN_PROJECTBASEDIR | ||
265 | +fi | ||
266 | +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" | ||
267 | + | ||
268 | +# For Cygwin, switch paths to Windows format before running java | ||
269 | +if $cygwin; then | ||
270 | + [ -n "$M2_HOME" ] && | ||
271 | + M2_HOME=`cygpath --path --windows "$M2_HOME"` | ||
272 | + [ -n "$JAVA_HOME" ] && | ||
273 | + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` | ||
274 | + [ -n "$CLASSPATH" ] && | ||
275 | + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` | ||
276 | + [ -n "$MAVEN_PROJECTBASEDIR" ] && | ||
277 | + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` | ||
278 | +fi | ||
279 | + | ||
280 | +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain | ||
281 | + | ||
282 | +exec "$JAVACMD" \ | ||
283 | + $MAVEN_OPTS \ | ||
284 | + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ | ||
285 | + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ | ||
286 | + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" |
mvnw.cmd
0 → 100644
1 | +@REM ---------------------------------------------------------------------------- | ||
2 | +@REM Licensed to the Apache Software Foundation (ASF) under one | ||
3 | +@REM or more contributor license agreements. See the NOTICE file | ||
4 | +@REM distributed with this work for additional information | ||
5 | +@REM regarding copyright ownership. The ASF licenses this file | ||
6 | +@REM to you under the Apache License, Version 2.0 (the | ||
7 | +@REM "License"); you may not use this file except in compliance | ||
8 | +@REM with the License. You may obtain a copy of the License at | ||
9 | +@REM | ||
10 | +@REM http://www.apache.org/licenses/LICENSE-2.0 | ||
11 | +@REM | ||
12 | +@REM Unless required by applicable law or agreed to in writing, | ||
13 | +@REM software distributed under the License is distributed on an | ||
14 | +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
15 | +@REM KIND, either express or implied. See the License for the | ||
16 | +@REM specific language governing permissions and limitations | ||
17 | +@REM under the License. | ||
18 | +@REM ---------------------------------------------------------------------------- | ||
19 | + | ||
20 | +@REM ---------------------------------------------------------------------------- | ||
21 | +@REM Maven2 Start Up Batch script | ||
22 | +@REM | ||
23 | +@REM Required ENV vars: | ||
24 | +@REM JAVA_HOME - location of a JDK home dir | ||
25 | +@REM | ||
26 | +@REM Optional ENV vars | ||
27 | +@REM M2_HOME - location of maven2's installed home dir | ||
28 | +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands | ||
29 | +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending | ||
30 | +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven | ||
31 | +@REM e.g. to debug Maven itself, use | ||
32 | +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 | ||
33 | +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files | ||
34 | +@REM ---------------------------------------------------------------------------- | ||
35 | + | ||
36 | +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' | ||
37 | +@echo off | ||
38 | +@REM set title of command window | ||
39 | +title %0 | ||
40 | +@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' | ||
41 | +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% | ||
42 | + | ||
43 | +@REM set %HOME% to equivalent of $HOME | ||
44 | +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") | ||
45 | + | ||
46 | +@REM Execute a user defined script before this one | ||
47 | +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre | ||
48 | +@REM check for pre script, once with legacy .bat ending and once with .cmd ending | ||
49 | +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" | ||
50 | +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" | ||
51 | +:skipRcPre | ||
52 | + | ||
53 | +@setlocal | ||
54 | + | ||
55 | +set ERROR_CODE=0 | ||
56 | + | ||
57 | +@REM To isolate internal variables from possible post scripts, we use another setlocal | ||
58 | +@setlocal | ||
59 | + | ||
60 | +@REM ==== START VALIDATION ==== | ||
61 | +if not "%JAVA_HOME%" == "" goto OkJHome | ||
62 | + | ||
63 | +echo. | ||
64 | +echo Error: JAVA_HOME not found in your environment. >&2 | ||
65 | +echo Please set the JAVA_HOME variable in your environment to match the >&2 | ||
66 | +echo location of your Java installation. >&2 | ||
67 | +echo. | ||
68 | +goto error | ||
69 | + | ||
70 | +:OkJHome | ||
71 | +if exist "%JAVA_HOME%\bin\java.exe" goto init | ||
72 | + | ||
73 | +echo. | ||
74 | +echo Error: JAVA_HOME is set to an invalid directory. >&2 | ||
75 | +echo JAVA_HOME = "%JAVA_HOME%" >&2 | ||
76 | +echo Please set the JAVA_HOME variable in your environment to match the >&2 | ||
77 | +echo location of your Java installation. >&2 | ||
78 | +echo. | ||
79 | +goto error | ||
80 | + | ||
81 | +@REM ==== END VALIDATION ==== | ||
82 | + | ||
83 | +:init | ||
84 | + | ||
85 | +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". | ||
86 | +@REM Fallback to current working directory if not found. | ||
87 | + | ||
88 | +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% | ||
89 | +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir | ||
90 | + | ||
91 | +set EXEC_DIR=%CD% | ||
92 | +set WDIR=%EXEC_DIR% | ||
93 | +:findBaseDir | ||
94 | +IF EXIST "%WDIR%"\.mvn goto baseDirFound | ||
95 | +cd .. | ||
96 | +IF "%WDIR%"=="%CD%" goto baseDirNotFound | ||
97 | +set WDIR=%CD% | ||
98 | +goto findBaseDir | ||
99 | + | ||
100 | +:baseDirFound | ||
101 | +set MAVEN_PROJECTBASEDIR=%WDIR% | ||
102 | +cd "%EXEC_DIR%" | ||
103 | +goto endDetectBaseDir | ||
104 | + | ||
105 | +:baseDirNotFound | ||
106 | +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% | ||
107 | +cd "%EXEC_DIR%" | ||
108 | + | ||
109 | +:endDetectBaseDir | ||
110 | + | ||
111 | +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig | ||
112 | + | ||
113 | +@setlocal EnableExtensions EnableDelayedExpansion | ||
114 | +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a | ||
115 | +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% | ||
116 | + | ||
117 | +:endReadAdditionalConfig | ||
118 | + | ||
119 | +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" | ||
120 | +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" | ||
121 | +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain | ||
122 | + | ||
123 | +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.4.2/maven-wrapper-0.4.2.jar" | ||
124 | +FOR /F "tokens=1,2 delims==" %%A IN (%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties) DO ( | ||
125 | + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B | ||
126 | +) | ||
127 | + | ||
128 | +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central | ||
129 | +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. | ||
130 | +if exist %WRAPPER_JAR% ( | ||
131 | + echo Found %WRAPPER_JAR% | ||
132 | +) else ( | ||
133 | + echo Couldn't find %WRAPPER_JAR%, downloading it ... | ||
134 | + echo Downloading from: %DOWNLOAD_URL% | ||
135 | + powershell -Command "(New-Object Net.WebClient).DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')" | ||
136 | + echo Finished downloading %WRAPPER_JAR% | ||
137 | +) | ||
138 | +@REM End of extension | ||
139 | + | ||
140 | +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* | ||
141 | +if ERRORLEVEL 1 goto error | ||
142 | +goto end | ||
143 | + | ||
144 | +:error | ||
145 | +set ERROR_CODE=1 | ||
146 | + | ||
147 | +:end | ||
148 | +@endlocal & set ERROR_CODE=%ERROR_CODE% | ||
149 | + | ||
150 | +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost | ||
151 | +@REM check for post script, once with legacy .bat ending and once with .cmd ending | ||
152 | +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" | ||
153 | +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" | ||
154 | +:skipRcPost | ||
155 | + | ||
156 | +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' | ||
157 | +if "%MAVEN_BATCH_PAUSE%" == "on" pause | ||
158 | + | ||
159 | +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% | ||
160 | + | ||
161 | +exit /B %ERROR_CODE% |
pom.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
3 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
4 | + <modelVersion>4.0.0</modelVersion> | ||
5 | + | ||
6 | + <groupId>com.example</groupId> | ||
7 | + <artifactId>demo</artifactId> | ||
8 | + <version>0.0.1-SNAPSHOT</version> | ||
9 | + <packaging>jar</packaging> | ||
10 | + | ||
11 | + <name>demo</name> | ||
12 | + <description>Demo project for Spring Boot</description> | ||
13 | + | ||
14 | + <parent> | ||
15 | + <groupId>org.springframework.boot</groupId> | ||
16 | + <artifactId>spring-boot-starter-parent</artifactId> | ||
17 | + <version>2.1.0.RELEASE</version> | ||
18 | + <relativePath/> <!-- lookup parent from repository --> | ||
19 | + </parent> | ||
20 | + | ||
21 | + <properties> | ||
22 | + <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
23 | + <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> | ||
24 | + <java.version>1.8</java.version> | ||
25 | + <spring-cloud.version>Greenwich.M1</spring-cloud.version> | ||
26 | + </properties> | ||
27 | + | ||
28 | + <dependencies> | ||
29 | + <dependency> | ||
30 | + <groupId>org.springframework.boot</groupId> | ||
31 | + <artifactId>spring-boot-starter-jdbc</artifactId> | ||
32 | + </dependency> | ||
33 | + <dependency> | ||
34 | + <groupId>org.springframework.boot</groupId> | ||
35 | + <artifactId>spring-boot-starter-web</artifactId> | ||
36 | + </dependency> | ||
37 | + <dependency> | ||
38 | + <groupId>org.mybatis.spring.boot</groupId> | ||
39 | + <artifactId>mybatis-spring-boot-starter</artifactId> | ||
40 | + <version>1.3.2</version> | ||
41 | + </dependency> | ||
42 | + | ||
43 | + <dependency> | ||
44 | + <groupId>mysql</groupId> | ||
45 | + <artifactId>mysql-connector-java</artifactId> | ||
46 | + <scope>runtime</scope> | ||
47 | + </dependency> | ||
48 | + <dependency> | ||
49 | + <groupId>org.springframework.boot</groupId> | ||
50 | + <artifactId>spring-boot-starter-test</artifactId> | ||
51 | + <scope>test</scope> | ||
52 | + </dependency> | ||
53 | + <dependency> | ||
54 | + <groupId>org.springframework.cloud</groupId> | ||
55 | + <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId> | ||
56 | + </dependency> | ||
57 | + <dependency> | ||
58 | + <groupId>com.github.pagehelper</groupId> | ||
59 | + <artifactId>pagehelper-spring-boot-starter</artifactId> | ||
60 | + <version>1.2.5</version> | ||
61 | + </dependency> | ||
62 | + <!-- alibaba的druid数据库连接池 --> | ||
63 | + <dependency> | ||
64 | + <groupId>com.alibaba</groupId> | ||
65 | + <artifactId>druid-spring-boot-starter</artifactId> | ||
66 | + <version>1.1.9</version> | ||
67 | + </dependency> | ||
68 | + <!-- https://mvnrepository.com/artifact/org.jdom/jdom --> | ||
69 | + <dependency> | ||
70 | + <groupId>org.jdom</groupId> | ||
71 | + <artifactId>jdom</artifactId> | ||
72 | + <version>1.1.3</version> | ||
73 | + </dependency> | ||
74 | + <!--log--> | ||
75 | + <dependency> | ||
76 | + <groupId>org.springframework.boot</groupId> | ||
77 | + <artifactId>spring-boot-starter-log4j2</artifactId> | ||
78 | + </dependency> | ||
79 | + <dependency> <!-- 加上这个才能辨认到log4j2.yml文件 --> | ||
80 | + <groupId>com.fasterxml.jackson.dataformat</groupId> | ||
81 | + <artifactId>jackson-dataformat-yaml</artifactId> | ||
82 | + </dependency> | ||
83 | + </dependencies> | ||
84 | + <dependencyManagement> | ||
85 | + <dependencies> | ||
86 | + <dependency> | ||
87 | + <groupId>org.springframework.cloud</groupId> | ||
88 | + <artifactId>spring-cloud-dependencies</artifactId> | ||
89 | + <version>${spring-cloud.version}</version> | ||
90 | + <type>pom</type> | ||
91 | + <scope>import</scope> | ||
92 | + </dependency> | ||
93 | + </dependencies> | ||
94 | + </dependencyManagement> | ||
95 | + <build> | ||
96 | + <plugins> | ||
97 | + <plugin> | ||
98 | + <groupId>org.springframework.boot</groupId> | ||
99 | + <artifactId>spring-boot-maven-plugin</artifactId> | ||
100 | + </plugin> | ||
101 | + <!-- mybatis generator 自动生成代码插件 --> | ||
102 | + <plugin> | ||
103 | + <groupId>org.mybatis.generator</groupId> | ||
104 | + <artifactId>mybatis-generator-maven-plugin</artifactId> | ||
105 | + <version>1.3.2</version> | ||
106 | + <configuration> | ||
107 | + <configurationFile>${basedir}/src/main/resources/generator/generatorConfig.xml</configurationFile> | ||
108 | + <overwrite>true</overwrite> | ||
109 | + <verbose>true</verbose> | ||
110 | + </configuration> | ||
111 | + </plugin> | ||
112 | + </plugins> | ||
113 | + </build> | ||
114 | + <repositories> | ||
115 | + <repository> | ||
116 | + <id>spring-milestones</id> | ||
117 | + <name>Spring Milestones</name> | ||
118 | + <url>https://repo.spring.io/milestone</url> | ||
119 | + <snapshots> | ||
120 | + <enabled>false</enabled> | ||
121 | + </snapshots> | ||
122 | + </repository> | ||
123 | + </repositories> | ||
124 | + | ||
125 | +</project> |
1 | +package com.example.demo; | ||
2 | + | ||
3 | +import com.example.demo.util.XML.XMLParse; | ||
4 | + | ||
5 | +import org.slf4j.Logger; | ||
6 | +import org.slf4j.LoggerFactory; | ||
7 | +import org.mybatis.spring.annotation.MapperScan; | ||
8 | + | ||
9 | +import org.springframework.boot.SpringApplication; | ||
10 | +import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
11 | +import org.springframework.cloud.netflix.eureka.EnableEurekaClient; | ||
12 | + | ||
13 | +import java.util.List; | ||
14 | +import java.util.Map; | ||
15 | + | ||
16 | +@SpringBootApplication | ||
17 | +@EnableEurekaClient | ||
18 | +@MapperScan("com.example.demo.mapper")//将项目中对应的mapper类的路径加进来就可以了 | ||
19 | +public class DemoApplication { | ||
20 | + | ||
21 | + public static void main(String[] args) { | ||
22 | + Logger logger = LoggerFactory.getLogger(DemoApplication.class); | ||
23 | + SpringApplication.run(DemoApplication.class, args); | ||
24 | + String testMsg= "<MSG>\n" + | ||
25 | + "\t<META>\n" + | ||
26 | + "\t\t<SNDR>TXD</SNDR>\n" + | ||
27 | + "\t\t<DDTM>20181109021010</DDTM>\n" + | ||
28 | + "\t\t<TYPE>DFME</TYPE>\n" + | ||
29 | + "\t\t<STYP>FWB</STYP>\n" + | ||
30 | + "\t\t<SEQN>4638010</SEQN>\n" + | ||
31 | + "\t</META>\n" + | ||
32 | + "\t<MasterConsignment>\n" + | ||
33 | + "\t\t<ID>479-77229622</ID>\n" + | ||
34 | + "\t\t<TypeCode>741</TypeCode>\n" + | ||
35 | + "\t\t<NilCarriageValueIndicator>false</NilCarriageValueIndicator>\n" + | ||
36 | + "\t\t<DeclaredValueForCarriageAmount currencyID=\"CNY\">0</DeclaredValueForCarriageAmount>\n" + | ||
37 | + "\t\t<NilCustomsValueIndicator>true</NilCustomsValueIndicator>\n" + | ||
38 | + "\t\t<DeclaredValueForCustomsAmount currencyID=\"CNY\">NCV</DeclaredValueForCustomsAmount>\n" + | ||
39 | + "\t\t<NilInsuranceValueIndicator>true</NilInsuranceValueIndicator>\n" + | ||
40 | + "\t\t<InsuranceValueAmount currencyID=\"CNY\">XXX</InsuranceValueAmount>\n" + | ||
41 | + "\t\t<TotalChargePrepaidIndicator>true</TotalChargePrepaidIndicator>\n" + | ||
42 | + "\t\t<WeightTotalChargeAmount currencyID=\"CNY\">1153</WeightTotalChargeAmount>\n" + | ||
43 | + "\t\t<ValuationTotalChargeAmount currencyID=\"CNY\">0.00</ValuationTotalChargeAmount>\n" + | ||
44 | + "\t\t<TotalDisbursementPrepaidIndicator>true</TotalDisbursementPrepaidIndicator>\n" + | ||
45 | + "\t\t<TotalPrepaidChargeAmount currencyID=\"CNY\">1384.00</TotalPrepaidChargeAmount>\n" + | ||
46 | + "\t\t<TotalCollectChargeAmount currencyID=\"CNY\">0</TotalCollectChargeAmount>\n" + | ||
47 | + "\t\t<DestinationCurrencyTotalCollectChargeAmount currencyID=\"CNY\">0</DestinationCurrencyTotalCollectChargeAmount>\n" + | ||
48 | + "\t\t<IncludedTareGrossWeightMeasure unitCode=\"KGM\">1153.0</IncludedTareGrossWeightMeasure>\n" + | ||
49 | + "\t\t<NetWeightMeasure/>\n" + | ||
50 | + "\t\t<GrossVolumeMeasure unitCode=\"MTQ\">2.7</GrossVolumeMeasure>\n" + | ||
51 | + "\t\t<TotalChargeableWeightMeasure unitCode=\"KGM\">1153.0</TotalChargeableWeightMeasure>\n" + | ||
52 | + "\t\t<ConsignmentItemQuantity>1</ConsignmentItemQuantity>\n" + | ||
53 | + "\t\t<TotalPieceQuantity>45</TotalPieceQuantity>\n" + | ||
54 | + "\t\t<TotalLoadedPackageQuantity>45</TotalLoadedPackageQuantity>\n" + | ||
55 | + "\t\t<PackageInfo>编织袋</PackageInfo>\n" + | ||
56 | + "\t\t<FreightRateTypeCode>Q</FreightRateTypeCode>\n" + | ||
57 | + "\t\t<ConsignorParty>\n" + | ||
58 | + "\t\t\t<PrimaryID schemeAgencyID=\"1\">FY</PrimaryID>\n" + | ||
59 | + "\t\t\t<Name>郑州飞鹰货运服务有限公司</Name>\n" + | ||
60 | + "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" + | ||
61 | + "\t\t\t<PostalStructuredAddress>\n" + | ||
62 | + "\t\t\t\t<StreetName>郑州</StreetName>\n" + | ||
63 | + "\t\t\t\t<CityName>CGO</CityName>\n" + | ||
64 | + "\t\t\t\t<CountryID>CN</CountryID>\n" + | ||
65 | + "\t\t\t\t<SpecifiedAddressLocation/>\n" + | ||
66 | + "\t\t\t</PostalStructuredAddress>\n" + | ||
67 | + "\t\t\t<SpecifiedCargoAgentLocation/>\n" + | ||
68 | + "\t\t\t<DefinedTradeContact>\n" + | ||
69 | + "\t\t\t\t<DirectTelephoneCommunication>\n" + | ||
70 | + "\t\t\t\t\t<CompleteNumber>13633854441</CompleteNumber>\n" + | ||
71 | + "\t\t\t\t</DirectTelephoneCommunication>\n" + | ||
72 | + "\t\t\t</DefinedTradeContact>\n" + | ||
73 | + "\t\t</ConsignorParty>\n" + | ||
74 | + "\t\t<ConsigneeParty>\n" + | ||
75 | + "\t\t\t<PrimaryID schemeAgencyID=\"2\">SK</PrimaryID>\n" + | ||
76 | + "\t\t\t<Name>深圳市联运通</Name>\n" + | ||
77 | + "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" + | ||
78 | + "\t\t\t<PostalStructuredAddress>\n" + | ||
79 | + "\t\t\t\t<StreetName>机场自提</StreetName>\n" + | ||
80 | + "\t\t\t\t<CityName>SZX</CityName>\n" + | ||
81 | + "\t\t\t\t<CountryID>CN</CountryID>\n" + | ||
82 | + "\t\t\t\t<SpecifiedAddressLocation/>\n" + | ||
83 | + "\t\t\t</PostalStructuredAddress>\n" + | ||
84 | + "\t\t\t<SpecifiedCargoAgentLocation/>\n" + | ||
85 | + "\t\t\t<DefinedTradeContact/>\n" + | ||
86 | + "\t\t</ConsigneeParty>\n" + | ||
87 | + "\t\t<FreightForwarderParty>\n" + | ||
88 | + "\t\t\t<Name>80210200</Name>\n" + | ||
89 | + "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" + | ||
90 | + "\t\t\t<PostalStructuredAddress>\n" + | ||
91 | + "\t\t\t\t<CityName>CGO</CityName>\n" + | ||
92 | + "\t\t\t\t<CountryID>CN</CountryID>\n" + | ||
93 | + "\t\t\t\t<SpecifiedAddressLocation/>\n" + | ||
94 | + "\t\t\t</PostalStructuredAddress>\n" + | ||
95 | + "\t\t\t<SpecifiedCargoAgentLocation/>\n" + | ||
96 | + "\t\t\t<DefinedTradeContact/>\n" + | ||
97 | + "\t\t</FreightForwarderParty>\n" + | ||
98 | + "\t\t<AssociatedParty>\n" + | ||
99 | + "\t\t\t<PrimaryID/>\n" + | ||
100 | + "\t\t\t<Name>CGO</Name>\n" + | ||
101 | + "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" + | ||
102 | + "\t\t\t<RoleCode>AGT</RoleCode>\n" + | ||
103 | + "\t\t\t<Role>Agent</Role>\n" + | ||
104 | + "\t\t\t<PostalStructuredAddress>\n" + | ||
105 | + "\t\t\t\t<CityName>CGO</CityName>\n" + | ||
106 | + "\t\t\t\t<CountryID>CN</CountryID>\n" + | ||
107 | + "\t\t\t\t<SpecifiedAddressLocation/>\n" + | ||
108 | + "\t\t\t</PostalStructuredAddress>\n" + | ||
109 | + "\t\t\t<SpecifiedCargoAgentLocation/>\n" + | ||
110 | + "\t\t\t<DefinedTradeContact/>\n" + | ||
111 | + "\t\t</AssociatedParty>\n" + | ||
112 | + "\t\t<AssociatedParty>\n" + | ||
113 | + "\t\t\t<PrimaryID/>\n" + | ||
114 | + "\t\t\t<Name>CGOHA</Name>\n" + | ||
115 | + "\t\t\t<AccountID>INFOSKY:NULL</AccountID>\n" + | ||
116 | + "\t\t\t<RoleCode>GHA</RoleCode>\n" + | ||
117 | + "\t\t\t<Role>Ground Handling Agent</Role>\n" + | ||
118 | + "\t\t\t<PostalStructuredAddress>\n" + | ||
119 | + "\t\t\t\t<CityName>CGO</CityName>\n" + | ||
120 | + "\t\t\t\t<CountryID>CN</CountryID>\n" + | ||
121 | + "\t\t\t\t<SpecifiedAddressLocation/>\n" + | ||
122 | + "\t\t\t</PostalStructuredAddress>\n" + | ||
123 | + "\t\t\t<SpecifiedCargoAgentLocation/>\n" + | ||
124 | + "\t\t\t<DefinedTradeContact/>\n" + | ||
125 | + "\t\t</AssociatedParty>\n" + | ||
126 | + "\t\t<OriginLocation>\n" + | ||
127 | + "\t\t\t<ID>CGO</ID>\n" + | ||
128 | + "\t\t</OriginLocation>\n" + | ||
129 | + "\t\t<FinalDestinationLocation>\n" + | ||
130 | + "\t\t\t<ID>SZX</ID>\n" + | ||
131 | + "\t\t</FinalDestinationLocation>\n" + | ||
132 | + "\t\t<SpecifiedLogisticsTransportMovement>\n" + | ||
133 | + "\t\t\t<StageCode>ZH9306/Nov09</StageCode>\n" + | ||
134 | + "\t\t\t<ModeCode>4</ModeCode>\n" + | ||
135 | + "\t\t\t<Mode>Air Transport</Mode>\n" + | ||
136 | + "\t\t\t<ID>ZH9306</ID>\n" + | ||
137 | + "\t\t\t<SequenceNumeric>1</SequenceNumeric>\n" + | ||
138 | + "\t\t\t<UsedLogisticsTransportMeans/>\n" + | ||
139 | + "\t\t\t<ArrivalEvent>\n" + | ||
140 | + "\t\t\t\t<OccurrenceArrivalLocation>\n" + | ||
141 | + "\t\t\t\t\t<ID>SZX</ID>\n" + | ||
142 | + "\t\t\t\t</OccurrenceArrivalLocation>\n" + | ||
143 | + "\t\t\t</ArrivalEvent>\n" + | ||
144 | + "\t\t\t<DepartureEvent>\n" + | ||
145 | + "\t\t\t\t<ScheduledOccurrenceDateTime>2018-11-09T00:00:00+08:00</ScheduledOccurrenceDateTime>\n" + | ||
146 | + "\t\t\t\t<OccurrenceDepartureLocation>\n" + | ||
147 | + "\t\t\t\t\t<ID>CGO</ID>\n" + | ||
148 | + "\t\t\t\t</OccurrenceDepartureLocation>\n" + | ||
149 | + "\t\t\t</DepartureEvent>\n" + | ||
150 | + "\t\t</SpecifiedLogisticsTransportMovement>\n" + | ||
151 | + "\t\t<HandlingInstructions>\n" + | ||
152 | + "\t\t\t<Description>ELI</Description>\n" + | ||
153 | + "\t\t\t<DescriptionCode>ELI</DescriptionCode>\n" + | ||
154 | + "\t\t</HandlingInstructions>\n" + | ||
155 | + "\t\t<AssociatedConsignmentCustomsProcedure/>\n" + | ||
156 | + "\t\t<ApplicableTradeCurrencyExchange>\n" + | ||
157 | + "\t\t\t<SourceCurrencyCode>CNY</SourceCurrencyCode>\n" + | ||
158 | + "\t\t\t<TargetCurrencyCode>CNY</TargetCurrencyCode>\n" + | ||
159 | + "\t\t\t<MarketID>S</MarketID>\n" + | ||
160 | + "\t\t\t<ConversionRate>1</ConversionRate>\n" + | ||
161 | + "\t\t</ApplicableTradeCurrencyExchange>\n" + | ||
162 | + "\t\t<ApplicableLogisticsServiceCharge/>\n" + | ||
163 | + "\t\t<ApplicableLogisticsAllowanceCharge>\n" + | ||
164 | + "\t\t\t<ID>MY</ID>\n" + | ||
165 | + "\t\t\t<Reason>燃油费</Reason>\n" + | ||
166 | + "\t\t\t<ActualAmount currencyID=\"CNY\">231</ActualAmount>\n" + | ||
167 | + "\t\t\t<PartyTypeCode>C</PartyTypeCode>\n" + | ||
168 | + "\t\t</ApplicableLogisticsAllowanceCharge>\n" + | ||
169 | + "\t\t<SignatoryCarrierAuthentication>\n" + | ||
170 | + "\t\t\t<ActualDateTime>2018-11-09T02:07:00</ActualDateTime>\n" + | ||
171 | + "\t\t\t<Signatory>郑天祥</Signatory>\n" + | ||
172 | + "\t\t\t<IssueAuthenticationLocation>\n" + | ||
173 | + "\t\t\t\t<Name>郑州</Name>\n" + | ||
174 | + "\t\t\t</IssueAuthenticationLocation>\n" + | ||
175 | + "\t\t</SignatoryCarrierAuthentication>\n" + | ||
176 | + "\t\t<IncludedMasterConsignmentItem>\n" + | ||
177 | + "\t\t\t<SequenceNumeric>1</SequenceNumeric>\n" + | ||
178 | + "\t\t\t<TypeCode listAgencyID=\"1\">SJ</TypeCode>\n" + | ||
179 | + "\t\t\t<GrossWeightMeasure unitCode=\"KGM\">1153.0</GrossWeightMeasure>\n" + | ||
180 | + "\t\t\t<GrossVolumeMeasure unitCode=\"MTQ\">2.7</GrossVolumeMeasure>\n" + | ||
181 | + "\t\t\t<PieceQuantity>45</PieceQuantity>\n" + | ||
182 | + "\t\t\t<TareWeightMeasure unitCode=\"KGM\">1153.0</TareWeightMeasure>\n" + | ||
183 | + "\t\t\t<NatureIdentificationTransportCargo>\n" + | ||
184 | + "\t\t\t\t<Identification>手机(内含锂离子电池符合包装说明PI967第二部分要求)</Identification>\n" + | ||
185 | + "\t\t\t</NatureIdentificationTransportCargo>\n" + | ||
186 | + "\t\t\t<OriginCountry/>\n" + | ||
187 | + "\t\t\t<AssociatedUnitLoadTransportEquipment>\n" + | ||
188 | + "\t\t\t\t<OperatingParty/>\n" + | ||
189 | + "\t\t\t</AssociatedUnitLoadTransportEquipment>\n" + | ||
190 | + "\t\t\t<TransportLogisticsPackage>\n" + | ||
191 | + "\t\t\t\t<ItemQuantity>45</ItemQuantity>\n" + | ||
192 | + "\t\t\t\t<LinearSpatialDimension>\n" + | ||
193 | + "\t\t\t\t\t<Description>true</Description>\n" + | ||
194 | + "\t\t\t\t\t<WidthMeasure unitCode=\"CMT\">40</WidthMeasure>\n" + | ||
195 | + "\t\t\t\t\t<LengthMeasure unitCode=\"CMT\">30</LengthMeasure>\n" + | ||
196 | + "\t\t\t\t\t<HeightMeasure unitCode=\"CMT\">50</HeightMeasure>\n" + | ||
197 | + "\t\t\t\t</LinearSpatialDimension>\n" + | ||
198 | + "\t\t\t</TransportLogisticsPackage>\n" + | ||
199 | + "\t\t\t<ApplicableFreightRateServiceCharge>\n" + | ||
200 | + "\t\t\t\t<CategoryCode>Q</CategoryCode>\n" + | ||
201 | + "\t\t\t\t<CommodityItemID>D2</CommodityItemID>\n" + | ||
202 | + "\t\t\t\t<ChargeableWeightMeasure unitCode=\"KGM\">1153.0</ChargeableWeightMeasure>\n" + | ||
203 | + "\t\t\t\t<AppliedRate>1</AppliedRate>\n" + | ||
204 | + "\t\t\t\t<AppliedAmount currencyID=\"CNY\">1153</AppliedAmount>\n" + | ||
205 | + "\t\t\t</ApplicableFreightRateServiceCharge>\n" + | ||
206 | + "\t\t\t<SpecifiedRateCombinationPointLocation/>\n" + | ||
207 | + "\t\t</IncludedMasterConsignmentItem>\n" + | ||
208 | + "\t\t<ReportedStatus>\n" + | ||
209 | + "\t\t\t<ReasonCode>FWB</ReasonCode>\n" + | ||
210 | + "\t\t\t<EventTime>\n" + | ||
211 | + "\t\t\t\t<OccurrenceDateTime>2018-11-09T02:07:15+08:00</OccurrenceDateTime>\n" + | ||
212 | + "\t\t\t\t<DateTimeTypeCode>Actual</DateTimeTypeCode>\n" + | ||
213 | + "\t\t\t</EventTime>\n" + | ||
214 | + "\t\t\t<SpecifiedLocation>\n" + | ||
215 | + "\t\t\t\t<ID>CGO</ID>\n" + | ||
216 | + "\t\t\t</SpecifiedLocation>\n" + | ||
217 | + "\t\t</ReportedStatus>\n" + | ||
218 | + "\t</MasterConsignment>\n" + | ||
219 | + "</MSG>"; | ||
220 | + try { | ||
221 | + XMLParse xmlParse = new XMLParse(testMsg, "/MSG/MasterConsignment/AssociatedParty"); | ||
222 | + List<Map> stype_value =xmlParse.getNodeValuesFromXmlString(); | ||
223 | + logger.info(stype_value.toString()); | ||
224 | + }catch (Exception var7){ | ||
225 | + System.out.print("there something wrong"); | ||
226 | + } | ||
227 | + } | ||
228 | +} |
1 | +package com.example.demo.controller; | ||
2 | + | ||
3 | +import com.example.demo.model.User; | ||
4 | +import com.example.demo.service.UserService; | ||
5 | +import org.springframework.beans.factory.annotation.Autowired; | ||
6 | +import org.springframework.stereotype.Controller; | ||
7 | +import org.springframework.web.bind.annotation.*; | ||
8 | + | ||
9 | +@Controller | ||
10 | +@RequestMapping(value = "/user") | ||
11 | +public class UserController { | ||
12 | + | ||
13 | + @Autowired | ||
14 | + private UserService userService; | ||
15 | + | ||
16 | + @ResponseBody | ||
17 | + @PostMapping("/add") | ||
18 | + public int addUser(User user){ | ||
19 | + return userService.insert(user); | ||
20 | + } | ||
21 | + | ||
22 | + @ResponseBody | ||
23 | + @GetMapping("all") | ||
24 | + public Object findAllUser( | ||
25 | + @RequestParam(name="pageNum",required = false,defaultValue = "1") | ||
26 | + int pageNum, | ||
27 | + @RequestParam(name = "pageSize",required = false,defaultValue = "10") | ||
28 | + int pageSize){ | ||
29 | + return userService.findAllUser(pageNum,pageSize); | ||
30 | + } | ||
31 | + | ||
32 | +} |
1 | +package com.example.demo.mapper; | ||
2 | + | ||
3 | +import com.example.demo.model.User; | ||
4 | + | ||
5 | +import java.util.List; | ||
6 | + | ||
7 | +public interface UserMapper { | ||
8 | + int deleteByPrimaryKey(Integer userId); | ||
9 | + | ||
10 | + int insert(User record); | ||
11 | + | ||
12 | + int insertSelective(User record); | ||
13 | + | ||
14 | + User selectByPrimaryKey(Integer userId); | ||
15 | + | ||
16 | + int updateByPrimaryKeySelective(User record); | ||
17 | + | ||
18 | + int updateByPrimaryKey(User record); | ||
19 | + | ||
20 | + List<User> selectUsers(); | ||
21 | +} |
1 | +package com.example.demo.model; | ||
2 | + | ||
3 | +import java.util.Date; | ||
4 | + | ||
5 | +public class User { | ||
6 | + private Integer userId; | ||
7 | + | ||
8 | + private String username; | ||
9 | + | ||
10 | + private String password; | ||
11 | + | ||
12 | + private Date birthday; | ||
13 | + | ||
14 | + private String sex; | ||
15 | + | ||
16 | + private String address; | ||
17 | + | ||
18 | + private Boolean state; | ||
19 | + | ||
20 | + private String mobilephone; | ||
21 | + | ||
22 | + private Date creatime; | ||
23 | + | ||
24 | + private Date updatetime; | ||
25 | + | ||
26 | + public Integer getUserId() { | ||
27 | + return userId; | ||
28 | + } | ||
29 | + | ||
30 | + public void setUserId(Integer userId) { | ||
31 | + this.userId = userId; | ||
32 | + } | ||
33 | + | ||
34 | + public String getUsername() { | ||
35 | + return username; | ||
36 | + } | ||
37 | + | ||
38 | + public void setUsername(String username) { | ||
39 | + this.username = username == null ? null : username.trim(); | ||
40 | + } | ||
41 | + | ||
42 | + public String getPassword() { | ||
43 | + return password; | ||
44 | + } | ||
45 | + | ||
46 | + public void setPassword(String password) { | ||
47 | + this.password = password == null ? null : password.trim(); | ||
48 | + } | ||
49 | + | ||
50 | + public Date getBirthday() { | ||
51 | + return birthday; | ||
52 | + } | ||
53 | + | ||
54 | + public void setBirthday(Date birthday) { | ||
55 | + this.birthday = birthday; | ||
56 | + } | ||
57 | + | ||
58 | + public String getSex() { | ||
59 | + return sex; | ||
60 | + } | ||
61 | + | ||
62 | + public void setSex(String sex) { | ||
63 | + this.sex = sex == null ? null : sex.trim(); | ||
64 | + } | ||
65 | + | ||
66 | + public String getAddress() { | ||
67 | + return address; | ||
68 | + } | ||
69 | + | ||
70 | + public void setAddress(String address) { | ||
71 | + this.address = address == null ? null : address.trim(); | ||
72 | + } | ||
73 | + | ||
74 | + public Boolean getState() { | ||
75 | + return state; | ||
76 | + } | ||
77 | + | ||
78 | + public void setState(Boolean state) { | ||
79 | + this.state = state; | ||
80 | + } | ||
81 | + | ||
82 | + public String getMobilephone() { | ||
83 | + return mobilephone; | ||
84 | + } | ||
85 | + | ||
86 | + public void setMobilephone(String mobilephone) { | ||
87 | + this.mobilephone = mobilephone == null ? null : mobilephone.trim(); | ||
88 | + } | ||
89 | + | ||
90 | + public Date getCreatime() { | ||
91 | + return creatime; | ||
92 | + } | ||
93 | + | ||
94 | + public void setCreatime(Date creatime) { | ||
95 | + this.creatime = creatime; | ||
96 | + } | ||
97 | + | ||
98 | + public Date getUpdatetime() { | ||
99 | + return updatetime; | ||
100 | + } | ||
101 | + | ||
102 | + public void setUpdatetime(Date updatetime) { | ||
103 | + this.updatetime = updatetime; | ||
104 | + } | ||
105 | +} |
1 | +package com.example.demo.service; | ||
2 | + | ||
3 | +import com.example.demo.model.User; | ||
4 | +import com.github.pagehelper.PageInfo; | ||
5 | + | ||
6 | + | ||
7 | +public interface UserService { | ||
8 | + int deleteByPrimaryKey(Integer userId); | ||
9 | + | ||
10 | + int insert(User record); | ||
11 | + | ||
12 | + int insertSelective(User record); | ||
13 | + | ||
14 | + User selectByPrimaryKey(Integer userId); | ||
15 | + | ||
16 | + int updateByPrimaryKeySelective(User record); | ||
17 | + | ||
18 | + int updateByPrimaryKey(User record); | ||
19 | + | ||
20 | + PageInfo<User> findAllUser(int pageNum, int pageSize); | ||
21 | +} |
1 | +package com.example.demo.service.imp; | ||
2 | + | ||
3 | +import com.example.demo.mapper.UserMapper; | ||
4 | +import com.example.demo.model.User; | ||
5 | +import com.example.demo.service.UserService; | ||
6 | +import com.github.pagehelper.PageHelper; | ||
7 | +import com.github.pagehelper.PageInfo; | ||
8 | +import org.springframework.beans.factory.annotation.Autowired; | ||
9 | +import org.springframework.stereotype.Service; | ||
10 | + | ||
11 | +import java.util.List; | ||
12 | + | ||
13 | +@Service(value = "userService") | ||
14 | +public class UserServiceImp implements UserService{ | ||
15 | + | ||
16 | + @Autowired | ||
17 | + private UserMapper userMapper; | ||
18 | + | ||
19 | + public int deleteByPrimaryKey(Integer userId){ | ||
20 | + return userMapper.deleteByPrimaryKey(userId); | ||
21 | + } | ||
22 | + | ||
23 | + public int insert(User record){ | ||
24 | + return userMapper.insert(record); | ||
25 | + } | ||
26 | + | ||
27 | + public int insertSelective(User record){ | ||
28 | + return userMapper.insertSelective(record); | ||
29 | + } | ||
30 | + | ||
31 | + public User selectByPrimaryKey(Integer userId){ | ||
32 | + return userMapper.selectByPrimaryKey(userId); | ||
33 | + } | ||
34 | + | ||
35 | + public int updateByPrimaryKeySelective(User record){ | ||
36 | + return userMapper.updateByPrimaryKeySelective(record); | ||
37 | + } | ||
38 | + | ||
39 | + public int updateByPrimaryKey(User record){ | ||
40 | + return userMapper.updateByPrimaryKey(record); | ||
41 | + } | ||
42 | + | ||
43 | + public PageInfo<User> findAllUser(int pageNum, int pageSize){ | ||
44 | + PageHelper.startPage(pageNum,pageSize); | ||
45 | + List<User> users = userMapper.selectUsers(); | ||
46 | + PageInfo<User> result = new PageInfo<User>(users); | ||
47 | + return result; | ||
48 | + | ||
49 | + } | ||
50 | +} |
1 | +package com.example.demo.util.XML; | ||
2 | + | ||
3 | +import org.jdom.Element; | ||
4 | + | ||
5 | +public class SubNode { | ||
6 | + private Element element; | ||
7 | + | ||
8 | + public SubNode(Element element) { | ||
9 | + this.element = element; | ||
10 | + } | ||
11 | + | ||
12 | + public Element getElement() { | ||
13 | + return this.element; | ||
14 | + } | ||
15 | + | ||
16 | + public void setElement(Element element) { | ||
17 | + this.element = element; | ||
18 | + } | ||
19 | +} |
1 | +package com.example.demo.util.XML; | ||
2 | + | ||
3 | +import ch.qos.logback.core.joran.spi.XMLUtil; | ||
4 | +import com.example.demo.DemoApplication; | ||
5 | +import org.jdom.Document; | ||
6 | +import org.jdom.Element; | ||
7 | +import org.jdom.JDOMException; | ||
8 | +import org.jdom.input.SAXBuilder; | ||
9 | +import org.slf4j.Logger; | ||
10 | +import org.slf4j.LoggerFactory; | ||
11 | +import org.xml.sax.InputSource; | ||
12 | + | ||
13 | +import java.io.IOException; | ||
14 | +import java.io.StringReader; | ||
15 | +import java.util.*; | ||
16 | + | ||
17 | +public class XMLParse { | ||
18 | + private static String xmlString; | ||
19 | + private static String[] nodes; | ||
20 | + private static Document document; | ||
21 | + private static SAXBuilder builder; | ||
22 | + private static Element root; | ||
23 | + private static LinkedList<SubNode> listNode; | ||
24 | + private static StringReader xmlReader; | ||
25 | + private static InputSource xmlSource; | ||
26 | + private String value; | ||
27 | + public XMLParse() { | ||
28 | + } | ||
29 | + Logger logger = LoggerFactory.getLogger(DemoApplication.class); | ||
30 | + /** | ||
31 | + * | ||
32 | + * @param xmlString xml字符窜 | ||
33 | + * @param xmlNodePath 节点参数(例如:/root/head/type) | ||
34 | + */ | ||
35 | + public XMLParse(String xmlString, String xmlNodePath) { | ||
36 | + this.xmlString = xmlString; | ||
37 | + this.nodes = xmlNodePath.split("/"); | ||
38 | + this.builder = new SAXBuilder(); | ||
39 | + this.root = null; | ||
40 | + this.listNode = new LinkedList(); | ||
41 | + this.value = ""; | ||
42 | + this.document =new Document(); | ||
43 | + } | ||
44 | + | ||
45 | + /** | ||
46 | + * 取一对多关系的节点下的所有子节点的属性名 和 值 | ||
47 | + * @return | ||
48 | + * @throws Exception | ||
49 | + */ | ||
50 | + public List<Map> getNodeValuesFromXmlString() throws Exception{ | ||
51 | + | ||
52 | + try { | ||
53 | + this.xmlReader = new StringReader(this.xmlString); | ||
54 | + this.xmlSource = new InputSource(this.xmlReader); | ||
55 | + this.document = this.builder.build(xmlSource); | ||
56 | + List<Map> maps = new ArrayList<Map>(); | ||
57 | + for(int i = 1; i < nodes.length; ++i) { | ||
58 | + SubNode snode; | ||
59 | + | ||
60 | + if (i >1) { | ||
61 | + snode = (SubNode)listNode.getLast(); | ||
62 | + List<Element> eList = snode.getElement().getChildren(nodes[i]); //这里等于3的时候得到associatedPary节点 两个,下面应该循环这两个element,取他下面的所有children | ||
63 | + if (eList != null && eList.size() > 0) { | ||
64 | + SubNode s1 = new SubNode((Element)eList.get(0)); | ||
65 | + listNode.add(s1); | ||
66 | + | ||
67 | + } | ||
68 | + if(eList != null && eList.size() > 1 && i==nodes.length-1){ //只有进入的最尾节点的时候再循环去取同名下的一对多的ELEMENT所有子节点 | ||
69 | + | ||
70 | + for (Element element : eList){ | ||
71 | + List<Element> elements=element.getChildren(); | ||
72 | + Map<String,String> childMap = new HashMap<String, String>(); //用map存储每个值 | ||
73 | + for (Element childElements : elements){ | ||
74 | + String childName = childElements.getName(); | ||
75 | + String childValue = childElements.getText(); | ||
76 | + childMap.put(childName,childValue); | ||
77 | + logger.debug(childValue); | ||
78 | + } | ||
79 | + maps.add(childMap); | ||
80 | + } | ||
81 | + } | ||
82 | + | ||
83 | + } else if (1 == i) { | ||
84 | + root = document.getRootElement(); | ||
85 | + snode = new SubNode(root); | ||
86 | + listNode.add(snode); | ||
87 | + } | ||
88 | + | ||
89 | + } | ||
90 | + return maps; | ||
91 | + } catch (Exception var17) { | ||
92 | + var17.printStackTrace(); | ||
93 | + throw var17; | ||
94 | + } finally { | ||
95 | + listNode.clear(); | ||
96 | + document = null; | ||
97 | + root = null; | ||
98 | + builder = null; | ||
99 | + nodes = null; | ||
100 | + } | ||
101 | + | ||
102 | + } | ||
103 | + | ||
104 | + /*** | ||
105 | + * 获取单一节点的值 | ||
106 | + * @return 单一节点值 | ||
107 | + * @throws Exception | ||
108 | + */ | ||
109 | + public final String getNodeValueFromXmlString() throws Exception { | ||
110 | + try { | ||
111 | + this.xmlReader = new StringReader(this.xmlString); | ||
112 | + this.xmlSource = new InputSource(this.xmlReader); | ||
113 | + this.document = this.builder.build(xmlSource); | ||
114 | + | ||
115 | + for(int i = 1; i < nodes.length; ++i) { | ||
116 | + SubNode snode; | ||
117 | + if (i > 1) { | ||
118 | + snode = (SubNode)listNode.getLast(); | ||
119 | + List<Element> eList = snode.getElement().getChildren(nodes[i]); | ||
120 | + if (eList != null && eList.size() > 0) { | ||
121 | + SubNode s1 = new SubNode((Element)eList.get(0)); | ||
122 | + listNode.add(s1); | ||
123 | + } | ||
124 | + } else if (1 == i) { | ||
125 | + root = document.getRootElement(); | ||
126 | + snode = new SubNode(root); | ||
127 | + listNode.add(snode); | ||
128 | + } | ||
129 | + } | ||
130 | + | ||
131 | + SubNode n = (SubNode)listNode.getLast(); | ||
132 | + value = n.getElement().getText(); | ||
133 | + n = null; | ||
134 | + return value; | ||
135 | + } catch (Exception var17) { | ||
136 | + var17.printStackTrace(); | ||
137 | + throw var17; | ||
138 | + } finally { | ||
139 | + listNode.clear(); | ||
140 | + document = null; | ||
141 | + root = null; | ||
142 | + builder = null; | ||
143 | + nodes = null; | ||
144 | + } | ||
145 | + | ||
146 | + } | ||
147 | + | ||
148 | + public static final String getNodeAttribute(String xmlFile, String xmlNodePath, String attributeName, String defaultValue) { | ||
149 | + String[] nodes = xmlNodePath.split("/"); | ||
150 | + new Document(); | ||
151 | + SAXBuilder builder = new SAXBuilder(); | ||
152 | + Element root = null; | ||
153 | + LinkedList<SubNode> listNode = new LinkedList(); | ||
154 | + String value = ""; | ||
155 | + | ||
156 | + Document document; | ||
157 | + try { | ||
158 | + document = builder.build(xmlFile); | ||
159 | + | ||
160 | + for(int i = 1; i < nodes.length; ++i) { | ||
161 | + SubNode snode; | ||
162 | + if (i > 1) { | ||
163 | + snode = (SubNode)listNode.getLast(); | ||
164 | + List<Element> eList = snode.getElement().getChildren(nodes[i]); | ||
165 | + if (eList != null && eList.size() > 0) { | ||
166 | + SubNode s1 = new SubNode((Element)eList.get(0)); | ||
167 | + listNode.add(s1); | ||
168 | + } | ||
169 | + } else if (1 == i) { | ||
170 | + root = document.getRootElement(); | ||
171 | + snode = new SubNode(root); | ||
172 | + listNode.add(snode); | ||
173 | + } | ||
174 | + } | ||
175 | + | ||
176 | + SubNode n = (SubNode)listNode.getLast(); | ||
177 | + value = n.getElement().getAttributeValue(attributeName, defaultValue); | ||
178 | + n = null; | ||
179 | + } catch (JDOMException var18) { | ||
180 | + var18.printStackTrace(); | ||
181 | + } catch (IOException var19) { | ||
182 | + var19.printStackTrace(); | ||
183 | + } finally { | ||
184 | + listNode.clear(); | ||
185 | + document = null; | ||
186 | + root = null; | ||
187 | + builder = null; | ||
188 | + nodes = null; | ||
189 | + } | ||
190 | + | ||
191 | + System.out.println("key=" + xmlNodePath + " node attrivte value=" + value); | ||
192 | + return value; | ||
193 | + } | ||
194 | +} |
src/main/resources/application.properties
0 → 100644
1 | + | ||
2 | +#服务端口 | ||
3 | +server.port=7002 | ||
4 | +#eureka主机名,会在控制页面中显示 | ||
5 | +eureka.instance.hostname=localhost | ||
6 | +#eureka服务器页面中status的请求路径 | ||
7 | +eureka.instance.status-page-url=http://localhost:7002/index | ||
8 | +#eureka注册中心服务器地址 | ||
9 | +eureka.client.service-url.defaultZone=http://localhost:7001/eureka/ | ||
10 | +#服务名 | ||
11 | +spring.application.name=fileServer-01 | ||
12 | + | ||
13 | +spring.datasource.name=test | ||
14 | +spring.datasource.url=jdbc:mysql://127.0.0.1:3307/statistics | ||
15 | +spring.datasource.username=root | ||
16 | +spring.datasource.password= | ||
17 | +#配置初始化大小/最小/最大 | ||
18 | +spring.datasource.druid.initial-size=1 | ||
19 | +spring.datasource.druid.min-idle=1 | ||
20 | +spring.datasource.druid.max-active=20 | ||
21 | +#获取连接等待超时时间 | ||
22 | +spring.datasource.druid.max-wait=60000 | ||
23 | +#一个连接在池中最小生存的时间 | ||
24 | +spring.datasource.druid.min-evictable-idle-time-millis=300000 | ||
25 | +#间隔多久进行一次检测,检测需要关闭的空闲连接 | ||
26 | +spring.datasource.druid.time-between-eviction-runs-millis=60000 | ||
27 | +spring.datasource.druid.validation-query=SELECT 'x' | ||
28 | +spring.datasource.druid.test-while-idle=true | ||
29 | +spring.datasource.druid.test-on-borrow=false | ||
30 | +spring.datasource.druid.test-on-return=false | ||
31 | +spring.datasource.type=com.alibaba.druid.pool.DruidDataSource | ||
32 | +spring.datasource.driver-class-name=com.mysql.jdbc.Driver | ||
33 | + | ||
34 | +mybatis.mapper-locations=classpath:mapping/*.xml | ||
35 | +mybatis.type-aliases-package=com.example.demo.model | ||
36 | + | ||
37 | +pagehelper.helper-dialect=mysql | ||
38 | +pagehelper.reasonable=true | ||
39 | +pagehelper.support-methods-arguments=true | ||
40 | +pagehelper.params=count=countSql | ||
41 | + | ||
42 | + |
1 | +<?xml version="1.0" encoding="UTF-8"?> | ||
2 | +<!DOCTYPE generatorConfiguration | ||
3 | + PUBLIC "-//mybatis.org//DTD MyBatis Generator Configuration 1.0//EN" | ||
4 | + "http://mybatis.org/dtd/mybatis-generator-config_1_0.dtd"> | ||
5 | +<generatorConfiguration> | ||
6 | + <!-- 数据库驱动:选择你的本地硬盘上面的数据库驱动包--> | ||
7 | + <classPathEntry location="/Users/mrz/Downloads/mybatis-generator-core-1.3.2/lib/mysql-connector-java-5.1.25-bin.jar"/> | ||
8 | + <context id="DB2Tables" targetRuntime="MyBatis3"> | ||
9 | + <commentGenerator> | ||
10 | + <property name="suppressDate" value="true"/> | ||
11 | + <!-- 是否去除自动生成的注释 true:是 : false:否 --> | ||
12 | + <property name="suppressAllComments" value="true"/> | ||
13 | + </commentGenerator> | ||
14 | + <!--数据库链接URL,用户名、密码 --> | ||
15 | + <jdbcConnection driverClass="com.mysql.jdbc.Driver" connectionURL="jdbc:mysql://127.0.0.1:3307/statistics" userId="root" password=""> | ||
16 | + </jdbcConnection> | ||
17 | + <javaTypeResolver> | ||
18 | + <property name="forceBigDecimals" value="false"/> | ||
19 | + </javaTypeResolver> | ||
20 | + <!-- 生成模型的包名和位置--> | ||
21 | + <javaModelGenerator targetPackage="com.example.demo.model" targetProject="src/main/java"> | ||
22 | + <property name="enableSubPackages" value="true"/> | ||
23 | + <property name="trimStrings" value="true"/> | ||
24 | + </javaModelGenerator> | ||
25 | + <!-- 生成映射文件的包名和位置--> | ||
26 | + <sqlMapGenerator targetPackage="mapping" targetProject="src/main/resources"> | ||
27 | + <property name="enableSubPackages" value="true"/> | ||
28 | + </sqlMapGenerator> | ||
29 | + <!-- 生成DAO的包名和位置--> | ||
30 | + <javaClientGenerator type="XMLMAPPER" targetPackage="com.example.demo.mapper" targetProject="src/main/java"> | ||
31 | + <property name="enableSubPackages" value="true"/> | ||
32 | + </javaClientGenerator> | ||
33 | + <!-- 要生成的表 tableName是数据库中的表名或视图名 domainObjectName是实体类名--> | ||
34 | + <table tableName="users" domainObjectName="User" enableCountByExample="false" enableUpdateByExample="false" enableDeleteByExample="false" enableSelectByExample="false" selectByExampleQueryId="false"></table> | ||
35 | + </context> | ||
36 | +</generatorConfiguration> |
src/main/resources/log4j2.yml
0 → 100644
1 | +Configuration: | ||
2 | + status: warn | ||
3 | + | ||
4 | + Properties: # 定义全局变量 | ||
5 | + Property: # 缺省配置(用于开发环境)。其他环境需要在VM参数中指定,如下: | ||
6 | + #测试:-Dlog.level.console=warn -Dlog.level.xjj=trace | ||
7 | + #生产:-Dlog.level.console=warn -Dlog.level.xjj=info | ||
8 | + - name: log.level.console | ||
9 | + value: trace | ||
10 | + - name: log.level.xjj | ||
11 | + value: trace | ||
12 | + - name: log.path | ||
13 | + value: /opt/logs | ||
14 | + - name: project.name | ||
15 | + value: my-spring-boot | ||
16 | + | ||
17 | + Appenders: | ||
18 | + Console: #输出到控制台 | ||
19 | + name: CONSOLE | ||
20 | + target: SYSTEM_OUT | ||
21 | + ThresholdFilter: | ||
22 | + level: ${sys:log.level.console} # “sys:”表示:如果VM参数中没指定这个变量值,则使用本文件中定义的缺省全局变量值 | ||
23 | + onMatch: ACCEPT | ||
24 | + onMismatch: DENY | ||
25 | + PatternLayout: | ||
26 | + pattern: "%d{yyyy-MM-dd HH:mm:ss,SSS}:%4p %t (%F:%L) - %m%n" | ||
27 | + RollingFile: # 输出到文件,超过128MB归档 | ||
28 | + - name: ROLLING_FILE | ||
29 | + ignoreExceptions: false | ||
30 | + fileName: ${log.path}/${project.name}.log | ||
31 | + filePattern: "${log.path}/$${date:yyyy-MM}/${project.name}-%d{yyyy-MM-dd}-%i.log.gz" | ||
32 | + PatternLayout: | ||
33 | + pattern: "%d{yyyy-MM-dd HH:mm:ss,SSS}:%4p %t (%F:%L) - %m%n" | ||
34 | + Policies: | ||
35 | + SizeBasedTriggeringPolicy: | ||
36 | + size: "128 MB" | ||
37 | + DefaultRolloverStrategy: | ||
38 | + max: 1000 | ||
39 | + | ||
40 | + Loggers: | ||
41 | + Root: | ||
42 | + level: info | ||
43 | + AppenderRef: | ||
44 | + - ref: CONSOLE | ||
45 | + - ref: ROLLING_FILE | ||
46 | + Logger: # 为com.xjj包配置特殊的Log级别,方便调试 | ||
47 | + - name: com.xjj | ||
48 | + additivity: false | ||
49 | + level: ${sys:log.level.xjj} | ||
50 | + AppenderRef: | ||
51 | + - ref: CONSOLE | ||
52 | + - ref: ROLLING_FILE |
src/main/resources/mapping/UserMapper.xml
0 → 100644
1 | +<?xml version="1.0" encoding="UTF-8" ?> | ||
2 | +<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > | ||
3 | +<mapper namespace="com.example.demo.mapper.UserMapper" > | ||
4 | + <resultMap id="BaseResultMap" type="com.example.demo.model.User" > | ||
5 | + <id column="user_id" property="userId" jdbcType="INTEGER" /> | ||
6 | + <result column="username" property="username" jdbcType="VARCHAR" /> | ||
7 | + <result column="password" property="password" jdbcType="VARCHAR" /> | ||
8 | + <result column="birthday" property="birthday" jdbcType="TIMESTAMP" /> | ||
9 | + <result column="sex" property="sex" jdbcType="CHAR" /> | ||
10 | + <result column="address" property="address" jdbcType="VARCHAR" /> | ||
11 | + <result column="state" property="state" jdbcType="BIT" /> | ||
12 | + <result column="mobilePhone" property="mobilephone" jdbcType="VARCHAR" /> | ||
13 | + <result column="creaTime" property="creatime" jdbcType="TIMESTAMP" /> | ||
14 | + <result column="updateTime" property="updatetime" jdbcType="TIMESTAMP" /> | ||
15 | + </resultMap> | ||
16 | + <sql id="Base_Table"> | ||
17 | + users | ||
18 | + </sql> | ||
19 | + <sql id="Base_Column_List" > | ||
20 | + user_id, username, password, birthday, sex, address, state, mobilePhone, creaTime, | ||
21 | + updateTime | ||
22 | + </sql> | ||
23 | + <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > | ||
24 | + select | ||
25 | + <include refid="Base_Column_List" /> | ||
26 | + from users | ||
27 | + where user_id = #{userId,jdbcType=INTEGER} | ||
28 | + </select> | ||
29 | + <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > | ||
30 | + delete from users | ||
31 | + where user_id = #{userId,jdbcType=INTEGER} | ||
32 | + </delete> | ||
33 | + <insert id="insert" parameterType="com.example.demo.model.User" > | ||
34 | + insert into users (user_id, username, password, | ||
35 | + birthday, sex, address, | ||
36 | + state, mobilePhone, creaTime, | ||
37 | + updateTime) | ||
38 | + values (#{userId,jdbcType=INTEGER}, #{username,jdbcType=VARCHAR}, #{password,jdbcType=VARCHAR}, | ||
39 | + #{birthday,jdbcType=TIMESTAMP}, #{sex,jdbcType=CHAR}, #{address,jdbcType=VARCHAR}, | ||
40 | + #{state,jdbcType=BIT}, #{mobilephone,jdbcType=VARCHAR}, #{creatime,jdbcType=TIMESTAMP}, | ||
41 | + #{updatetime,jdbcType=TIMESTAMP}) | ||
42 | + </insert> | ||
43 | + <insert id="insertSelective" parameterType="com.example.demo.model.User" > | ||
44 | + insert into users | ||
45 | + <trim prefix="(" suffix=")" suffixOverrides="," > | ||
46 | + <if test="userId != null" > | ||
47 | + user_id, | ||
48 | + </if> | ||
49 | + <if test="username != null" > | ||
50 | + username, | ||
51 | + </if> | ||
52 | + <if test="password != null" > | ||
53 | + password, | ||
54 | + </if> | ||
55 | + <if test="birthday != null" > | ||
56 | + birthday, | ||
57 | + </if> | ||
58 | + <if test="sex != null" > | ||
59 | + sex, | ||
60 | + </if> | ||
61 | + <if test="address != null" > | ||
62 | + address, | ||
63 | + </if> | ||
64 | + <if test="state != null" > | ||
65 | + state, | ||
66 | + </if> | ||
67 | + <if test="mobilephone != null" > | ||
68 | + mobilePhone, | ||
69 | + </if> | ||
70 | + <if test="creatime != null" > | ||
71 | + creaTime, | ||
72 | + </if> | ||
73 | + <if test="updatetime != null" > | ||
74 | + updateTime, | ||
75 | + </if> | ||
76 | + </trim> | ||
77 | + <trim prefix="values (" suffix=")" suffixOverrides="," > | ||
78 | + <if test="userId != null" > | ||
79 | + #{userId,jdbcType=INTEGER}, | ||
80 | + </if> | ||
81 | + <if test="username != null" > | ||
82 | + #{username,jdbcType=VARCHAR}, | ||
83 | + </if> | ||
84 | + <if test="password != null" > | ||
85 | + #{password,jdbcType=VARCHAR}, | ||
86 | + </if> | ||
87 | + <if test="birthday != null" > | ||
88 | + #{birthday,jdbcType=TIMESTAMP}, | ||
89 | + </if> | ||
90 | + <if test="sex != null" > | ||
91 | + #{sex,jdbcType=CHAR}, | ||
92 | + </if> | ||
93 | + <if test="address != null" > | ||
94 | + #{address,jdbcType=VARCHAR}, | ||
95 | + </if> | ||
96 | + <if test="state != null" > | ||
97 | + #{state,jdbcType=BIT}, | ||
98 | + </if> | ||
99 | + <if test="mobilephone != null" > | ||
100 | + #{mobilephone,jdbcType=VARCHAR}, | ||
101 | + </if> | ||
102 | + <if test="creatime != null" > | ||
103 | + #{creatime,jdbcType=TIMESTAMP}, | ||
104 | + </if> | ||
105 | + <if test="updatetime != null" > | ||
106 | + #{updatetime,jdbcType=TIMESTAMP}, | ||
107 | + </if> | ||
108 | + </trim> | ||
109 | + </insert> | ||
110 | + <update id="updateByPrimaryKeySelective" parameterType="com.example.demo.model.User" > | ||
111 | + update users | ||
112 | + <set > | ||
113 | + <if test="username != null" > | ||
114 | + username = #{username,jdbcType=VARCHAR}, | ||
115 | + </if> | ||
116 | + <if test="password != null" > | ||
117 | + password = #{password,jdbcType=VARCHAR}, | ||
118 | + </if> | ||
119 | + <if test="birthday != null" > | ||
120 | + birthday = #{birthday,jdbcType=TIMESTAMP}, | ||
121 | + </if> | ||
122 | + <if test="sex != null" > | ||
123 | + sex = #{sex,jdbcType=CHAR}, | ||
124 | + </if> | ||
125 | + <if test="address != null" > | ||
126 | + address = #{address,jdbcType=VARCHAR}, | ||
127 | + </if> | ||
128 | + <if test="state != null" > | ||
129 | + state = #{state,jdbcType=BIT}, | ||
130 | + </if> | ||
131 | + <if test="mobilephone != null" > | ||
132 | + mobilePhone = #{mobilephone,jdbcType=VARCHAR}, | ||
133 | + </if> | ||
134 | + <if test="creatime != null" > | ||
135 | + creaTime = #{creatime,jdbcType=TIMESTAMP}, | ||
136 | + </if> | ||
137 | + <if test="updatetime != null" > | ||
138 | + updateTime = #{updatetime,jdbcType=TIMESTAMP}, | ||
139 | + </if> | ||
140 | + </set> | ||
141 | + where user_id = #{userId,jdbcType=INTEGER} | ||
142 | + </update> | ||
143 | + <update id="updateByPrimaryKey" parameterType="com.example.demo.model.User" > | ||
144 | + update users | ||
145 | + set username = #{username,jdbcType=VARCHAR}, | ||
146 | + password = #{password,jdbcType=VARCHAR}, | ||
147 | + birthday = #{birthday,jdbcType=TIMESTAMP}, | ||
148 | + sex = #{sex,jdbcType=CHAR}, | ||
149 | + address = #{address,jdbcType=VARCHAR}, | ||
150 | + state = #{state,jdbcType=BIT}, | ||
151 | + mobilePhone = #{mobilephone,jdbcType=VARCHAR}, | ||
152 | + creaTime = #{creatime,jdbcType=TIMESTAMP}, | ||
153 | + updateTime = #{updatetime,jdbcType=TIMESTAMP} | ||
154 | + where user_id = #{userId,jdbcType=INTEGER} | ||
155 | + </update> | ||
156 | + | ||
157 | + <select id="selectUsers" resultType="com.example.demo.model.User"> | ||
158 | + SELECT | ||
159 | + <include refid="Base_Column_List"/> | ||
160 | + FROM | ||
161 | + <include refid="Base_Table"/> | ||
162 | + </select> | ||
163 | +</mapper> |
1 | +package com.example.demo; | ||
2 | + | ||
3 | +import org.junit.Test; | ||
4 | +import org.junit.runner.RunWith; | ||
5 | +import org.springframework.boot.test.context.SpringBootTest; | ||
6 | +import org.springframework.test.context.junit4.SpringRunner; | ||
7 | + | ||
8 | +@RunWith(SpringRunner.class) | ||
9 | +@SpringBootTest | ||
10 | +public class DemoApplicationTests { | ||
11 | + | ||
12 | + @Test | ||
13 | + public void contextLoads() { | ||
14 | + } | ||
15 | + | ||
16 | +} |
-
请 注册 或 登录 后发表评论