新增mybatis和jackson的demo

master
barney 1 year ago
parent 2c8c6c2d87
commit e3395a56e9
  1. 33
      JsonStudy/.gitignore
  2. BIN
      JsonStudy/.mvn/wrapper/maven-wrapper.jar
  3. 18
      JsonStudy/.mvn/wrapper/maven-wrapper.properties
  4. 316
      JsonStudy/mvnw
  5. 188
      JsonStudy/mvnw.cmd
  6. 69
      JsonStudy/pom.xml
  7. 11
      JsonStudy/src/main/java/cc/bnblogs/jsonstudy/JsonStudyApplication.java
  8. 17
      JsonStudy/src/main/java/cc/bnblogs/jsonstudy/config/JacksonConfig.java
  9. 20
      JsonStudy/src/main/java/cc/bnblogs/jsonstudy/controller/IndexController.java
  10. 41
      JsonStudy/src/main/java/cc/bnblogs/jsonstudy/pojo/User.java
  11. 21
      JsonStudy/src/main/java/cc/bnblogs/jsonstudy/utils/UserSerializer.java
  12. 6
      JsonStudy/src/main/resources/application.yml
  13. 84
      JsonStudy/src/test/java/cc/bnblogs/jsonstudy/JsonStudyApplicationTests.java
  14. 108
      SpringDataJPA/logs/spring-info.log
  15. 19
      SpringDataJPA/pom.xml
  16. 31
      SpringDataJPA/spring-info.log
  17. 93
      SpringDataJPA/springInfo.log
  18. 2
      SpringDataJPA/src/main/java/cc/bnblogs/springdatajpa/config/filter/JwtAuthenticationTokenFilter.java
  19. 23
      SpringDataJPA/src/main/java/cc/bnblogs/springdatajpa/controller/DemoController.java
  20. 7
      SpringDataJPA/src/main/java/cc/bnblogs/springdatajpa/controller/UserController.java
  21. 2
      SpringDataJPA/src/main/java/cc/bnblogs/springdatajpa/service/impl/user/UserInfoServiceImpl.java
  22. 140
      SpringDataJPA/src/main/java/cc/bnblogs/springdatajpa/utils/custom/JsonPathStudy.java
  23. 148
      SpringDataJPA/src/main/java/cc/bnblogs/springdatajpa/utils/custom/MarkdownFileUtils.java
  24. 129
      SpringDataJPA/src/main/java/cc/bnblogs/springdatajpa/utils/custom/TestJsonPath3.java
  25. 7
      SpringDataJPA/src/main/resources/application.yml
  26. 37
      SpringDataJPA/src/main/resources/static/data.json
  27. 6
      SpringDataJPA/src/test/java/cc/bnblogs/springdatajpa/SpringDataJpaApplicationTests.java
  28. 82
      SpringDataJPA/src/test/java/cc/bnblogs/springdatajpa/utils/custom/JsonPathStudyTest.java
  29. 0
      demo/.idea/.gitignore
  30. 0
      demo/.idea/compiler.xml
  31. 0
      demo/.idea/encodings.xml
  32. 0
      demo/.idea/jarRepositories.xml
  33. 0
      demo/.idea/misc.xml
  34. 0
      demo/.idea/uiDesigner.xml
  35. 0
      demo/pom.xml
  36. 0
      demo/src/main/java/cc/bnblogs/demo/User.java
  37. 0
      demo/src/main/java/cc/bnblogs/test/TestSpring.java
  38. 0
      demo/src/main/resources/bean1.xml
  39. 0
      demo/target/classes/bean1.xml
  40. 0
      demo/target/classes/cc/bnblogs/demo/User.class
  41. 0
      demo/target/classes/cc/bnblogs/test/TestSpring.class
  42. 0
      demo/target/classes/classpath.index
  43. 33
      mybatisPlus_study/.gitignore
  44. BIN
      mybatisPlus_study/.mvn/wrapper/maven-wrapper.jar
  45. 18
      mybatisPlus_study/.mvn/wrapper/maven-wrapper.properties
  46. 316
      mybatisPlus_study/mvnw
  47. 188
      mybatisPlus_study/mvnw.cmd
  48. 86
      mybatisPlus_study/pom.xml
  49. 0
      mybatisPlus_study/src/main/java/cc/bnblogs/mybatis_study/MybatisStudyApplication.java
  50. 0
      mybatisPlus_study/src/main/java/cc/bnblogs/mybatis_study/config/MybatisConfig.java
  51. 0
      mybatisPlus_study/src/main/java/cc/bnblogs/mybatis_study/controller/UserController.java
  52. 0
      mybatisPlus_study/src/main/java/cc/bnblogs/mybatis_study/mapper/UserMapper.java
  53. 0
      mybatisPlus_study/src/main/java/cc/bnblogs/mybatis_study/pojo/User.java
  54. 0
      mybatisPlus_study/src/main/java/cc/bnblogs/mybatis_study/service/UserService.java
  55. 11
      mybatisPlus_study/src/main/resources/application.properties
  56. 0
      mybatisPlus_study/src/test/java/cc/bnblogs/mybatis_study/MybatisStudyApplicationTests.java
  57. 36
      mybatis_study/pom.xml
  58. 21
      mybatis_study/src/main/java/cc/bnblogs/newdemo/NewDemoApplication.java
  59. 19
      mybatis_study/src/main/java/cc/bnblogs/newdemo/bean/BlogProperties.java
  60. 17
      mybatis_study/src/main/java/cc/bnblogs/newdemo/bean/ConfigBean.java
  61. 19
      mybatis_study/src/main/java/cc/bnblogs/newdemo/bean/TestConfigBean.java
  62. 34
      mybatis_study/src/main/java/cc/bnblogs/newdemo/controller/BlogInfoController.java
  63. 17
      mybatis_study/src/main/java/cc/bnblogs/newdemo/controller/IndexController.java
  64. 57
      mybatis_study/src/main/java/cc/bnblogs/newdemo/controller/UserController.java
  65. 24
      mybatis_study/src/main/java/cc/bnblogs/newdemo/mapper/BlogInfoMapper.java
  66. 72
      mybatis_study/src/main/java/cc/bnblogs/newdemo/mapper/UserMapper.java
  67. 20
      mybatis_study/src/main/java/cc/bnblogs/newdemo/pojo/BlogInfo.java
  68. 20
      mybatis_study/src/main/java/cc/bnblogs/newdemo/pojo/User.java
  69. 2
      mybatis_study/src/main/resources/application-dev.yml
  70. 2
      mybatis_study/src/main/resources/application-prod.yml
  71. 4
      mybatis_study/src/main/resources/application.properties
  72. 68
      mybatis_study/src/main/resources/application.yml
  73. 9
      mybatis_study/src/main/resources/banner.txt
  74. 3
      mybatis_study/src/main/resources/blog.properties
  75. 61
      mybatis_study/src/main/resources/mapper/userMapper.xml
  76. 13
      mybatis_study/src/test/java/cc/bnblogs/newdemo/NewDemoApplicationTests.java

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

Binary file not shown.

@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar

316
JsonStudy/mvnw vendored

@ -0,0 +1,316 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`\\unset -f command; \\command -v java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

188
JsonStudy/mvnw.cmd vendored

@ -0,0 +1,188 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%

@ -0,0 +1,69 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.9</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>cc.bnblogs</groupId>
<artifactId>JsonStudy</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>JsonStudy</name>
<description>JsonStudy</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,11 @@
package cc.bnblogs.jsonstudy;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class JsonStudyApplication {
public static void main(String[] args) {
SpringApplication.run(JsonStudyApplication.class, args);
}
}

@ -0,0 +1,17 @@
package cc.bnblogs.jsonstudy.config;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.text.SimpleDateFormat;
@Configuration
public class JacksonConfig {
@Bean
public ObjectMapper getObjectMapper(){
ObjectMapper mapper = new ObjectMapper();
mapper.setDateFormat(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"));
return mapper;
}
}

@ -0,0 +1,20 @@
package cc.bnblogs.jsonstudy.controller;
import cc.bnblogs.jsonstudy.pojo.User;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
/**
* @description:
* @author: zfp@bnblogs.cc
* @date: 2023/3/18 22:57
*/
@RestController
public class IndexController {
@GetMapping
public User getUser() {
return new User(1,"tom",18,new Date());
}
}

@ -0,0 +1,41 @@
package cc.bnblogs.jsonstudy.pojo;
import cc.bnblogs.jsonstudy.utils.UserSerializer;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.annotation.JsonNaming;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* @description: 用户实体
* @author: zfp@bnblogs.cc
* @date: 2023/3/18 22:41
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
/*
@JsonIgnoreProperties忽略一组属性作用于类上
*/
@JsonIgnoreProperties({"id","age"})
@JsonSerialize(using = UserSerializer.class) // 使用注解@JsonSerialize来指定User对象的序列化方式
public class User implements Serializable {
private static final long serialVersionUID = -1716994393946400799L;
/**
* @JsonIgnore
* 添加该注解在某个属性上将不对该属性序列化和反序列化
*/
// @JsonIgnore
private Integer id;
private String name;
private Integer age;
private Date birth;
}

@ -0,0 +1,21 @@
package cc.bnblogs.jsonstudy.utils;
import cc.bnblogs.jsonstudy.pojo.User;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import java.io.IOException;
public class UserSerializer extends JsonSerializer<User> {
@Override
public void serialize(User user, JsonGenerator generator, SerializerProvider provider)
throws IOException {
generator.writeStartObject();
generator.writeStringField("user-name", user.getName());
generator.writeEndObject();
}
}

@ -0,0 +1,6 @@
spring:
datasource:
username: root
password: 123456
url: jdbc:mysql://192.168.153.135:3306/test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8
driver-class-name: com.mysql.cj.jdbc.Driver

@ -0,0 +1,84 @@
package cc.bnblogs.jsonstudy;
import cc.bnblogs.jsonstudy.pojo.User;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.SimpleTimeZone;
@SpringBootTest
class JsonStudyApplicationTests {
@Autowired
private ObjectMapper objectMapper;
/**
* java对象序列化为json
*
* @throws JsonProcessingException
*/
@Test
void objectToJson() throws JsonProcessingException {
User user = new User(1, "tom", 18, new Date());
String str = objectMapper.writeValueAsString(user);
System.out.println(str);
}
/**
* json反序列化
*
* @throws JsonProcessingException
*/
@Test
public void readJsonString() throws JsonProcessingException {
// 解析json对象
User user = new User(1, "tom", 18, new Date());
String str = objectMapper.writeValueAsString(user);
JsonNode node = objectMapper.readTree(str);
int id = node.get("id").asInt();
String name = node.get("name").asText();
int age = node.get("age").asInt();
System.out.println(id);
System.out.println(name + " : " + age);
// 更复杂的例子
String JsonStr = "{\n" + " \"store\": {\n" + " \"book\": [\n" + " {\n" + " \"category\": \"reference\",\n" + " \"author\": \"Nigel Rees\",\n" + " \"title\": \"Sayings of the Century\",\n" + " \"price\": 8.95\n" + " },\n" + " {\n" + " \"category\": \"fiction\",\n" + " \"author\": \"Evelyn Waugh\",\n" + " \"title\": \"Sword of Honour\",\n" + " \"price\": 12.99\n" + " },\n" + " {\n" + " \"category\": \"fiction\",\n" + " \"author\": \"Herman Melville\",\n" + " \"title\": \"Moby Dick\",\n" + " \"isbn\": \"0-553-21311-3\",\n" + " \"price\": 8.99\n" + " },\n" + " {\n" + " \"category\": \"fiction\",\n" + " \"author\": \"J. R. R. Tolkien\",\n" + " \"title\": \"The Lord of the Rings\",\n" + " \"isbn\": \"0-395-19395-8\",\n" + " \"price\": 22.99\n" + " }\n" + " ],\n" + " \"bicycle\": {\n" + " \"color\": \"red\",\n" + " \"price\": 19.95\n" + " }\n" + " },\n" + " \"expensive\": 10\n" + "}\n";
node = objectMapper.readTree(JsonStr);
String str1 = node.get("store").get("book").get(0).get("category").asText();
System.out.println(str1);
int price = node.get("expensive").asInt();
System.out.println(price);
}
/**
* Java对象和JSON数据进行绑定
* 读取json字符串中的内容到java对象中
*/
@Test
void readJsonAsObject() {
try {
String json = "{\"id\":1,\"name\":\"tom\",\"age\":18,\"birth\":\"2023-03-18 23:57:49\"}";
/*
注意要添加User类的无参构造方法否则会报错
*/
User user = objectMapper.readValue(json, User.class);
String name = user.getName();
int age = user.getAge();
Date birth = user.getBirth();
// 设置时间打印格式
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(sdf.format(birth));
System.out.println(name + " " + age);
} catch (Exception e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,108 @@
2023-03-10 00:22:33.004 INFO 17776 --- [restartedMain] c.b.s.SpringDataJpaApplication : Starting SpringDataJpaApplication using Java 1.8.0_342 on DESKTOP-G5S5LHL with PID 17776 (D:\spring_study\SpringDataJPA\target\classes started by 15270 in D:\spring_study\SpringDataJPA)
2023-03-10 00:22:33.005 INFO 17776 --- [restartedMain] c.b.s.SpringDataJpaApplication : No active profile set, falling back to 1 default profile: "default"
2023-03-10 00:22:33.038 INFO 17776 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-03-10 00:22:33.039 INFO 17776 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-03-10 00:22:33.483 INFO 17776 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-03-10 00:22:33.523 INFO 17776 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 33 ms. Found 1 JPA repository interfaces.
2023-03-10 00:22:33.928 INFO 17776 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-03-10 00:22:33.929 INFO 17776 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : Loaded Apache Tomcat Native library [1.2.33] using APR version [1.7.0].
2023-03-10 00:22:33.929 INFO 17776 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
2023-03-10 00:22:33.929 INFO 17776 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2023-03-10 00:22:33.932 INFO 17776 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.1o 3 May 2022]
2023-03-10 00:22:33.941 INFO 17776 --- [restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-03-10 00:22:33.941 INFO 17776 --- [restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.69]
2023-03-10 00:22:34.016 INFO 17776 --- [restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-03-10 00:22:34.016 INFO 17776 --- [restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 977 ms
2023-03-10 00:22:34.124 INFO 17776 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-03-10 00:22:34.160 INFO 17776 --- [restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final
2023-03-10 00:22:34.322 INFO 17776 --- [restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2023-03-10 00:22:34.398 INFO 17776 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-03-10 00:22:34.615 INFO 17776 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2023-03-10 00:22:34.629 INFO 17776 --- [restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2023-03-10 00:22:35.011 INFO 17776 --- [restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-03-10 00:22:35.017 INFO 17776 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-03-10 00:22:35.366 WARN 17776 --- [restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2023-03-10 00:22:35.467 INFO 17776 --- [restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@4dcdcaf9, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@432e404, org.springframework.security.web.context.SecurityContextPersistenceFilter@2e86ec29, org.springframework.security.web.header.HeaderWriterFilter@60f25f4a, org.springframework.security.web.authentication.logout.LogoutFilter@435a5b71, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@72bef81f, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@16c25b67, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@464f7268, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@4951416d, org.springframework.security.web.session.SessionManagementFilter@46235d83, org.springframework.security.web.access.ExceptionTranslationFilter@7c351bae, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@33cdae31]
2023-03-10 00:22:35.832 INFO 17776 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2023-03-10 00:22:35.859 INFO 17776 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2023-03-10 00:22:35.868 INFO 17776 --- [restartedMain] c.b.s.SpringDataJpaApplication : Started SpringDataJpaApplication in 3.214 seconds (JVM running for 4.144)
2023-03-10 00:22:41.421 INFO 17776 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-03-10 00:22:41.423 INFO 17776 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-03-10 00:22:41.427 INFO 17776 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2023-03-10 00:42:53.221 INFO 15980 --- [main] c.b.s.SpringDataJpaApplicationTests : Starting SpringDataJpaApplicationTests using Java 1.8.0_342 on DESKTOP-G5S5LHL with PID 15980 (started by 15270 in D:\spring_study\SpringDataJPA)
2023-03-10 00:42:53.222 INFO 15980 --- [main] c.b.s.SpringDataJpaApplicationTests : No active profile set, falling back to 1 default profile: "default"
2023-03-10 00:42:53.883 INFO 15980 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-03-10 00:42:53.942 INFO 15980 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 49 ms. Found 1 JPA repository interfaces.
2023-03-10 00:42:54.545 INFO 15980 --- [main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-03-10 00:42:54.591 INFO 15980 --- [main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final
2023-03-10 00:42:54.772 INFO 15980 --- [main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2023-03-10 00:42:55.238 INFO 15980 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-03-10 00:42:55.528 INFO 15980 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2023-03-10 00:42:55.558 INFO 15980 --- [main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2023-03-10 00:42:56.123 INFO 15980 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-03-10 00:42:56.131 INFO 15980 --- [main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-03-10 00:42:56.186 WARN 15980 --- [main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2023-03-10 00:42:57.017 INFO 15980 --- [main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@4e8afdad, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@79b8ecb, org.springframework.security.web.context.SecurityContextPersistenceFilter@4348fa35, org.springframework.security.web.header.HeaderWriterFilter@30704f85, org.springframework.security.web.authentication.logout.LogoutFilter@5abbb273, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@79b7c350, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@38cb1606, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@56872fcb, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@3722f39d, org.springframework.security.web.session.SessionManagementFilter@1029cf9, org.springframework.security.web.access.ExceptionTranslationFilter@6abe62bb, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@4d065e1a]
2023-03-10 00:42:57.730 INFO 15980 --- [main] c.b.s.SpringDataJpaApplicationTests : Started SpringDataJpaApplicationTests in 4.842 seconds (JVM running for 5.87)
2023-03-10 00:42:57.814 INFO 15980 --- [main] c.b.s.SpringDataJpaApplicationTests : Info 日志...
2023-03-10 00:42:57.814 WARN 15980 --- [main] c.b.s.SpringDataJpaApplicationTests : Warn 日志...
2023-03-10 00:42:57.815 ERROR 15980 --- [main] c.b.s.SpringDataJpaApplicationTests : Error 日志...
2023-03-10 00:42:57.831 INFO 15980 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-03-10 00:42:57.833 INFO 15980 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-03-10 00:42:57.838 INFO 15980 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2023-03-10 00:44:48.236 INFO 13664 --- [main] c.b.s.SpringDataJpaApplicationTests : Starting SpringDataJpaApplicationTests using Java 1.8.0_342 on DESKTOP-G5S5LHL with PID 13664 (started by 15270 in D:\spring_study\SpringDataJPA)
2023-03-10 00:44:48.238 INFO 13664 --- [main] c.b.s.SpringDataJpaApplicationTests : No active profile set, falling back to 1 default profile: "default"
2023-03-10 00:44:48.831 INFO 13664 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-03-10 00:44:48.885 INFO 13664 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 48 ms. Found 1 JPA repository interfaces.
2023-03-10 00:44:49.438 INFO 13664 --- [main] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-03-10 00:44:49.485 INFO 13664 --- [main] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final
2023-03-10 00:44:49.667 INFO 13664 --- [main] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2023-03-10 00:44:50.148 INFO 13664 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-03-10 00:44:50.447 INFO 13664 --- [main] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2023-03-10 00:44:50.478 INFO 13664 --- [main] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2023-03-10 00:44:51.051 INFO 13664 --- [main] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-03-10 00:44:51.058 INFO 13664 --- [main] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-03-10 00:44:51.118 WARN 13664 --- [main] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2023-03-10 00:44:51.972 INFO 13664 --- [main] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@3722f39d, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@4ec8d9b2, org.springframework.security.web.context.SecurityContextPersistenceFilter@61c4cebd, org.springframework.security.web.header.HeaderWriterFilter@1de12397, org.springframework.security.web.authentication.logout.LogoutFilter@445058e8, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@4cd7e993, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@716ae973, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@5d3b6585, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@57b63253, org.springframework.security.web.session.SessionManagementFilter@4348fa35, org.springframework.security.web.access.ExceptionTranslationFilter@29c25bbc, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@6dbbdf92]
2023-03-10 00:44:52.762 INFO 13664 --- [main] c.b.s.SpringDataJpaApplicationTests : Started SpringDataJpaApplicationTests in 4.9 seconds (JVM running for 5.956)
2023-03-10 00:44:52.768 INFO 13664 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-03-10 00:44:52.770 INFO 13664 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-03-10 00:44:52.775 INFO 13664 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2023-03-10 00:44:59.262 INFO 4060 --- [restartedMain] c.b.s.SpringDataJpaApplication : Starting SpringDataJpaApplication using Java 1.8.0_342 on DESKTOP-G5S5LHL with PID 4060 (D:\spring_study\SpringDataJPA\target\classes started by 15270 in D:\spring_study\SpringDataJPA)
2023-03-10 00:44:59.263 INFO 4060 --- [restartedMain] c.b.s.SpringDataJpaApplication : No active profile set, falling back to 1 default profile: "default"
2023-03-10 00:44:59.297 INFO 4060 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-03-10 00:44:59.297 INFO 4060 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-03-10 00:44:59.767 INFO 4060 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-03-10 00:44:59.810 INFO 4060 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 35 ms. Found 1 JPA repository interfaces.
2023-03-10 00:45:00.211 INFO 4060 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-03-10 00:45:00.212 INFO 4060 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : Loaded Apache Tomcat Native library [1.2.33] using APR version [1.7.0].
2023-03-10 00:45:00.212 INFO 4060 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
2023-03-10 00:45:00.213 INFO 4060 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2023-03-10 00:45:00.215 INFO 4060 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.1o 3 May 2022]
2023-03-10 00:45:00.221 INFO 4060 --- [restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-03-10 00:45:00.221 INFO 4060 --- [restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.69]
2023-03-10 00:45:00.287 INFO 4060 --- [restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-03-10 00:45:00.287 INFO 4060 --- [restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 989 ms
2023-03-10 00:45:00.396 INFO 4060 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-03-10 00:45:00.427 INFO 4060 --- [restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final
2023-03-10 00:45:00.541 INFO 4060 --- [restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2023-03-10 00:45:00.640 INFO 4060 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-03-10 00:45:00.852 INFO 4060 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2023-03-10 00:45:00.866 INFO 4060 --- [restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2023-03-10 00:45:01.298 INFO 4060 --- [restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-03-10 00:45:01.304 INFO 4060 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-03-10 00:45:01.732 WARN 4060 --- [restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2023-03-10 00:45:01.848 INFO 4060 --- [restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@4951416d, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@35ce8515, org.springframework.security.web.context.SecurityContextPersistenceFilter@16c25b67, org.springframework.security.web.header.HeaderWriterFilter@325452bc, org.springframework.security.web.authentication.logout.LogoutFilter@4c6e832, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@6359aed6, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6dfd384d, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@29446ba2, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@16771b57, org.springframework.security.web.session.SessionManagementFilter@2e86ec29, org.springframework.security.web.access.ExceptionTranslationFilter@7dee01bd, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@1f618dd7]
2023-03-10 00:45:02.241 INFO 4060 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2023-03-10 00:45:02.267 INFO 4060 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2023-03-10 00:45:02.276 INFO 4060 --- [restartedMain] c.b.s.SpringDataJpaApplication : Started SpringDataJpaApplication in 3.366 seconds (JVM running for 4.299)
2023-03-10 00:45:17.005 INFO 4060 --- [http-nio-8080-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring DispatcherServlet 'dispatcherServlet'
2023-03-10 00:45:17.005 INFO 4060 --- [http-nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Initializing Servlet 'dispatcherServlet'
2023-03-10 00:45:17.006 INFO 4060 --- [http-nio-8080-exec-1] o.s.web.servlet.DispatcherServlet : Completed initialization in 1 ms
2023-03-10 00:45:17.109 WARN 4060 --- [http-nio-8080-exec-1] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'POST' not supported]
2023-03-10 00:45:19.820 INFO 4060 --- [http-nio-8080-exec-4] c.b.s.controller.DemoController : Info 日志...
2023-03-10 00:45:19.820 WARN 4060 --- [http-nio-8080-exec-4] c.b.s.controller.DemoController : Warn 日志...
2023-03-10 00:45:19.820 ERROR 4060 --- [http-nio-8080-exec-4] c.b.s.controller.DemoController : Error 日志...
2023-03-10 00:45:35.166 INFO 4060 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-03-10 00:45:35.169 INFO 4060 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-03-10 00:45:35.173 INFO 4060 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.

@ -76,11 +76,30 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.8</version>
</dependency>
<dependency>
<groupId>com.jayway.jsonpath</groupId>
<artifactId>json-path</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>

@ -0,0 +1,31 @@
2023-03-09 23:08:14.765 INFO 11840 --- [restartedMain] c.b.s.SpringDataJpaApplication : Starting SpringDataJpaApplication using Java 1.8.0_342 on DESKTOP-G5S5LHL with PID 11840 (D:\spring_study\SpringDataJPA\target\classes started by 15270 in D:\spring_study\SpringDataJPA)
2023-03-09 23:08:14.766 INFO 11840 --- [restartedMain] c.b.s.SpringDataJpaApplication : No active profile set, falling back to 1 default profile: "default"
2023-03-09 23:08:14.797 INFO 11840 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-03-09 23:08:14.797 INFO 11840 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-03-09 23:08:15.234 INFO 11840 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-03-09 23:08:15.274 INFO 11840 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 33 ms. Found 1 JPA repository interfaces.
2023-03-09 23:08:15.661 INFO 11840 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-03-09 23:08:15.661 INFO 11840 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : Loaded Apache Tomcat Native library [1.2.33] using APR version [1.7.0].
2023-03-09 23:08:15.661 INFO 11840 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
2023-03-09 23:08:15.662 INFO 11840 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2023-03-09 23:08:15.664 INFO 11840 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.1o 3 May 2022]
2023-03-09 23:08:15.670 INFO 11840 --- [restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-03-09 23:08:15.671 INFO 11840 --- [restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.69]
2023-03-09 23:08:15.736 INFO 11840 --- [restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-03-09 23:08:15.736 INFO 11840 --- [restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 938 ms
2023-03-09 23:08:15.842 INFO 11840 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-03-09 23:08:15.874 INFO 11840 --- [restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final
2023-03-09 23:08:16.037 INFO 11840 --- [restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2023-03-09 23:08:16.103 INFO 11840 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-03-09 23:08:16.306 INFO 11840 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2023-03-09 23:08:16.320 INFO 11840 --- [restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2023-03-09 23:08:16.699 INFO 11840 --- [restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-03-09 23:08:16.706 INFO 11840 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-03-09 23:08:17.048 WARN 11840 --- [restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2023-03-09 23:08:17.141 INFO 11840 --- [restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@597b9c9c, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@c3d72c6, org.springframework.security.web.context.SecurityContextPersistenceFilter@41f6e3b3, org.springframework.security.web.header.HeaderWriterFilter@290505c9, org.springframework.security.web.authentication.logout.LogoutFilter@80207b1, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@162307, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6cca6049, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@6da3d80c, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@757af85, org.springframework.security.web.session.SessionManagementFilter@366682f5, org.springframework.security.web.access.ExceptionTranslationFilter@71946170, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@174dee51]
2023-03-09 23:08:17.484 INFO 11840 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2023-03-09 23:08:17.510 INFO 11840 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2023-03-09 23:08:17.518 INFO 11840 --- [restartedMain] c.b.s.SpringDataJpaApplication : Started SpringDataJpaApplication in 3.075 seconds (JVM running for 3.988)
2023-03-09 23:08:19.758 INFO 11840 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-03-09 23:08:19.761 INFO 11840 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-03-09 23:08:19.765 INFO 11840 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.

@ -0,0 +1,93 @@
2023-03-09 23:09:31.498 INFO 17884 --- [restartedMain] c.b.s.SpringDataJpaApplication : Starting SpringDataJpaApplication using Java 1.8.0_342 on DESKTOP-G5S5LHL with PID 17884 (D:\spring_study\SpringDataJPA\target\classes started by 15270 in D:\spring_study\SpringDataJPA)
2023-03-09 23:09:31.499 INFO 17884 --- [restartedMain] c.b.s.SpringDataJpaApplication : No active profile set, falling back to 1 default profile: "default"
2023-03-09 23:09:31.536 INFO 17884 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-03-09 23:09:31.537 INFO 17884 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-03-09 23:09:32.064 INFO 17884 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-03-09 23:09:32.111 INFO 17884 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 38 ms. Found 1 JPA repository interfaces.
2023-03-09 23:09:32.577 INFO 17884 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-03-09 23:09:32.578 INFO 17884 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : Loaded Apache Tomcat Native library [1.2.33] using APR version [1.7.0].
2023-03-09 23:09:32.578 INFO 17884 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
2023-03-09 23:09:32.578 INFO 17884 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2023-03-09 23:09:32.580 INFO 17884 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.1o 3 May 2022]
2023-03-09 23:09:32.587 INFO 17884 --- [restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-03-09 23:09:32.587 INFO 17884 --- [restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.69]
2023-03-09 23:09:32.659 INFO 17884 --- [restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-03-09 23:09:32.659 INFO 17884 --- [restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 1122 ms
2023-03-09 23:09:32.796 INFO 17884 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-03-09 23:09:32.839 INFO 17884 --- [restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final
2023-03-09 23:09:32.997 INFO 17884 --- [restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2023-03-09 23:09:33.079 INFO 17884 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-03-09 23:09:33.307 INFO 17884 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2023-03-09 23:09:33.324 INFO 17884 --- [restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2023-03-09 23:09:33.795 INFO 17884 --- [restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-03-09 23:09:33.803 INFO 17884 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-03-09 23:09:38.959 WARN 17884 --- [restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2023-03-09 23:09:39.073 INFO 17884 --- [restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@21ac7335, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@7ef3d18b, org.springframework.security.web.context.SecurityContextPersistenceFilter@1f839629, org.springframework.security.web.header.HeaderWriterFilter@4205e440, org.springframework.security.web.authentication.logout.LogoutFilter@10acdda1, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@75824183, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@1855c1cb, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@1788d9c7, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@3a90dff6, org.springframework.security.web.session.SessionManagementFilter@68749117, org.springframework.security.web.access.ExceptionTranslationFilter@78a6aec1, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@43bdc8e]
2023-03-09 23:09:39.458 INFO 17884 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2023-03-09 23:09:39.487 INFO 17884 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2023-03-09 23:09:39.497 INFO 17884 --- [restartedMain] c.b.s.SpringDataJpaApplication : Started SpringDataJpaApplication in 8.371 seconds (JVM running for 9.45)
2023-03-09 23:09:39.829 INFO 17884 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-03-09 23:09:39.832 INFO 17884 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-03-09 23:09:39.836 INFO 17884 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2023-03-09 23:09:43.396 INFO 8032 --- [restartedMain] c.b.s.SpringDataJpaApplication : Starting SpringDataJpaApplication using Java 1.8.0_342 on DESKTOP-G5S5LHL with PID 8032 (D:\spring_study\SpringDataJPA\target\classes started by 15270 in D:\spring_study\SpringDataJPA)
2023-03-09 23:09:43.397 INFO 8032 --- [restartedMain] c.b.s.SpringDataJpaApplication : No active profile set, falling back to 1 default profile: "default"
2023-03-09 23:09:43.433 INFO 8032 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-03-09 23:09:43.433 INFO 8032 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-03-09 23:09:43.866 INFO 8032 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-03-09 23:09:43.905 INFO 8032 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 33 ms. Found 1 JPA repository interfaces.
2023-03-09 23:09:44.299 INFO 8032 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-03-09 23:09:44.299 INFO 8032 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : Loaded Apache Tomcat Native library [1.2.33] using APR version [1.7.0].
2023-03-09 23:09:44.300 INFO 8032 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
2023-03-09 23:09:44.300 INFO 8032 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2023-03-09 23:09:44.302 INFO 8032 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.1o 3 May 2022]
2023-03-09 23:09:44.308 INFO 8032 --- [restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-03-09 23:09:44.308 INFO 8032 --- [restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.69]
2023-03-09 23:09:44.374 INFO 8032 --- [restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-03-09 23:09:44.374 INFO 8032 --- [restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 941 ms
2023-03-09 23:09:44.488 INFO 8032 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-03-09 23:09:44.521 INFO 8032 --- [restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final
2023-03-09 23:09:44.685 INFO 8032 --- [restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2023-03-09 23:09:44.751 INFO 8032 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-03-09 23:09:44.959 INFO 8032 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2023-03-09 23:09:44.973 INFO 8032 --- [restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2023-03-09 23:09:45.358 INFO 8032 --- [restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-03-09 23:09:45.364 INFO 8032 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-03-09 23:09:45.729 WARN 8032 --- [restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2023-03-09 23:09:45.824 INFO 8032 --- [restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@178645dc, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@72964e58, org.springframework.security.web.context.SecurityContextPersistenceFilter@540bf6e1, org.springframework.security.web.header.HeaderWriterFilter@4274053b, org.springframework.security.web.authentication.logout.LogoutFilter@16585494, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@2fcc2b7d, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@626e04dc, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@435a5b71, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@bd8afdc, org.springframework.security.web.session.SessionManagementFilter@24df04a0, org.springframework.security.web.access.ExceptionTranslationFilter@74036540, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@29cb615b]
2023-03-09 23:09:46.185 INFO 8032 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2023-03-09 23:09:46.210 INFO 8032 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2023-03-09 23:09:46.218 INFO 8032 --- [restartedMain] c.b.s.SpringDataJpaApplication : Started SpringDataJpaApplication in 3.146 seconds (JVM running for 4.035)
2023-03-09 23:09:50.084 INFO 8032 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-03-09 23:09:50.086 INFO 8032 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-03-09 23:09:50.090 INFO 8032 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.
2023-03-09 23:11:02.382 INFO 6924 --- [restartedMain] c.b.s.SpringDataJpaApplication : Starting SpringDataJpaApplication using Java 1.8.0_342 on DESKTOP-G5S5LHL with PID 6924 (D:\spring_study\SpringDataJPA\target\classes started by 15270 in D:\spring_study\SpringDataJPA)
2023-03-09 23:11:02.383 INFO 6924 --- [restartedMain] c.b.s.SpringDataJpaApplication : No active profile set, falling back to 1 default profile: "default"
2023-03-09 23:11:02.414 INFO 6924 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : Devtools property defaults active! Set 'spring.devtools.add-properties' to 'false' to disable
2023-03-09 23:11:02.414 INFO 6924 --- [restartedMain] .e.DevToolsPropertyDefaultsPostProcessor : For additional web related logging consider setting the 'logging.level.web' property to 'DEBUG'
2023-03-09 23:11:02.861 INFO 6924 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data JPA repositories in DEFAULT mode.
2023-03-09 23:11:02.900 INFO 6924 --- [restartedMain] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 33 ms. Found 1 JPA repository interfaces.
2023-03-09 23:11:03.291 INFO 6924 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2023-03-09 23:11:03.292 INFO 6924 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : Loaded Apache Tomcat Native library [1.2.33] using APR version [1.7.0].
2023-03-09 23:11:03.292 INFO 6924 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true], UDS [true].
2023-03-09 23:11:03.292 INFO 6924 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : APR/OpenSSL configuration: useAprConnector [false], useOpenSSL [true]
2023-03-09 23:11:03.294 INFO 6924 --- [restartedMain] o.a.catalina.core.AprLifecycleListener : OpenSSL successfully initialized [OpenSSL 1.1.1o 3 May 2022]
2023-03-09 23:11:03.300 INFO 6924 --- [restartedMain] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2023-03-09 23:11:03.300 INFO 6924 --- [restartedMain] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.69]
2023-03-09 23:11:03.365 INFO 6924 --- [restartedMain] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2023-03-09 23:11:03.365 INFO 6924 --- [restartedMain] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 951 ms
2023-03-09 23:11:03.469 INFO 6924 --- [restartedMain] o.hibernate.jpa.internal.util.LogHelper : HHH000204: Processing PersistenceUnitInfo [name: default]
2023-03-09 23:11:03.499 INFO 6924 --- [restartedMain] org.hibernate.Version : HHH000412: Hibernate ORM core version 5.6.14.Final
2023-03-09 23:11:03.647 INFO 6924 --- [restartedMain] o.hibernate.annotations.common.Version : HCANN000001: Hibernate Commons Annotations {5.1.2.Final}
2023-03-09 23:11:03.711 INFO 6924 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Starting...
2023-03-09 23:11:03.913 INFO 6924 --- [restartedMain] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Start completed.
2023-03-09 23:11:03.927 INFO 6924 --- [restartedMain] org.hibernate.dialect.Dialect : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2023-03-09 23:11:04.301 INFO 6924 --- [restartedMain] o.h.e.t.j.p.i.JtaPlatformInitiator : HHH000490: Using JtaPlatform implementation: [org.hibernate.engine.transaction.jta.platform.internal.NoJtaPlatform]
2023-03-09 23:11:04.307 INFO 6924 --- [restartedMain] j.LocalContainerEntityManagerFactoryBean : Initialized JPA EntityManagerFactory for persistence unit 'default'
2023-03-09 23:11:04.651 WARN 6924 --- [restartedMain] JpaBaseConfiguration$JpaWebConfiguration : spring.jpa.open-in-view is enabled by default. Therefore, database queries may be performed during view rendering. Explicitly configure spring.jpa.open-in-view to disable this warning
2023-03-09 23:11:04.753 INFO 6924 --- [restartedMain] o.s.s.web.DefaultSecurityFilterChain : Will secure any request with [org.springframework.security.web.session.DisableEncodeUrlFilter@4dcdcaf9, org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@432e404, org.springframework.security.web.context.SecurityContextPersistenceFilter@2e86ec29, org.springframework.security.web.header.HeaderWriterFilter@60f25f4a, org.springframework.security.web.authentication.logout.LogoutFilter@435a5b71, cc.bnblogs.springdatajpa.config.filter.JwtAuthenticationTokenFilter@72bef81f, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@16c25b67, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@464f7268, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@4951416d, org.springframework.security.web.session.SessionManagementFilter@46235d83, org.springframework.security.web.access.ExceptionTranslationFilter@7c351bae, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@33cdae31]
2023-03-09 23:11:05.096 INFO 6924 --- [restartedMain] o.s.b.d.a.OptionalLiveReloadServer : LiveReload server is running on port 35729
2023-03-09 23:11:05.121 INFO 6924 --- [restartedMain] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s): 8080 (http) with context path ''
2023-03-09 23:11:05.128 INFO 6924 --- [restartedMain] c.b.s.SpringDataJpaApplication : Started SpringDataJpaApplication in 3.061 seconds (JVM running for 3.96)
2023-03-09 23:11:10.249 INFO 6924 --- [SpringApplicationShutdownHook] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2023-03-09 23:11:10.251 INFO 6924 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown initiated...
2023-03-09 23:11:10.255 INFO 6924 --- [SpringApplicationShutdownHook] com.zaxxer.hikari.HikariDataSource : HikariPool-1 - Shutdown completed.

@ -4,7 +4,7 @@ import cc.bnblogs.springdatajpa.mapper.UserMapper;
import cc.bnblogs.springdatajpa.pojo.User;
import cc.bnblogs.springdatajpa.service.impl.security.UserDetailsImpl;
import cc.bnblogs.springdatajpa.utils.JwtUtil;
import com.sun.istack.internal.NotNull;
import com.sun.istack.NotNull;
import io.jsonwebtoken.Claims;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;

@ -0,0 +1,23 @@
package cc.bnblogs.springdatajpa.controller;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @description:
* @author: zfp@bnblogs.cc
* @date: 2023/3/10 0:43
*/
@RestController
@Slf4j
public class DemoController {
@GetMapping("/test/")
public void test() {
log.trace("Trace 日志...");
log.debug("Debug 日志...");
log.info("Info 日志...");
log.warn("Warn 日志...");
log.error("Error 日志...");
}
}

@ -1,17 +1,10 @@
package cc.bnblogs.springdatajpa.controller;
import cc.bnblogs.springdatajpa.mapper.UserMapper;
import cc.bnblogs.springdatajpa.pojo.User;
import cc.bnblogs.springdatajpa.pojo.model.UserModel;
import cc.bnblogs.springdatajpa.service.impl.user.LoginServiceImpl;
import cc.bnblogs.springdatajpa.service.impl.user.RegisterServiceImpl;
import cc.bnblogs.springdatajpa.service.impl.user.UserInfoServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**

@ -2,6 +2,7 @@ package cc.bnblogs.springdatajpa.service.impl.user;
import cc.bnblogs.springdatajpa.pojo.User;
import cc.bnblogs.springdatajpa.service.impl.security.UserDetailsImpl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Service;
@ -15,6 +16,7 @@ import java.util.Map;
* @date: 2023/3/8 22:12
*/
@Service
@Slf4j
public class UserInfoServiceImpl {
/**

@ -0,0 +1,140 @@
package cc.bnblogs.springdatajpa.utils.custom;
/**
* @description:
* @author: zfp@bnblogs.cc
* @date: 2023/3/9 16:19
*/
import com.jayway.jsonpath.JsonPath;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Iterator;
import java.util.List;
public class JsonPathStudy {
public static void main(String[] args) {
String myJson = readJson();
print("--------------------------------------getJsonValue--------------------------------------");
getJsonValue(myJson);
}
private static String readJson() {
StringBuilder sb = new StringBuilder();
try {
FileReader fr = new FileReader("src/main/resources/static/data.json");
BufferedReader bfd = new BufferedReader(fr);
String s = "";
while((s=bfd.readLine())!=null) {
sb.append(s);
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(sb);
return sb.toString();
}
private static void getJsonValue(String json) {
//The authors of all books:获取json中store下book下的所有author值
List<String> authors1 = JsonPath.read(json, "$.store.book[*].author");
//All authors:获取所有json中所有author的值
List<String> authors2 = JsonPath.read(json, "$..author");
//All things, both books and bicycles
//authors3返回的是net.minidev.json.JSONArray:获取json中store下的所有value值,不包含key,如key有两个,book和bicycle
List<Object> authors3 = JsonPath.read(json, "$.store.*");
//The price of everything:获取json中store下所有price的值
List<Object> authors4 = JsonPath.read(json, "$.store..price");
//The third book:获取json中book数组的第3个值
List<Object> authors5 = JsonPath.read(json, "$..book[2]");
//The first two books:获取json中book数组的第1和第2两个个值
List<Object> authors6 = JsonPath.read(json, "$..book[0,1]");
//All books from index 0 (inclusive) until index 2 (exclusive):获取json中book数组的前两个区间值
List<Object> authors7 = JsonPath.read(json, "$..book[:2]");
//All books from index 1 (inclusive) until index 2 (exclusive):获取json中book数组的第2个值
List<Object> authors8 = JsonPath.read(json, "$..book[1:2]");
//Last two books:获取json中book数组的最后两个值
List<Object> authors9 = JsonPath.read(json, "$..book[-2:]");
//Book number two from tail:获取json中book数组的第3个到最后一个的区间值
List<Object> authors10 = JsonPath.read(json, "$..book[2:]");
//All books with an ISBN number:获取json中book数组中包含isbn的所有值
List<Object> authors11 = JsonPath.read(json, "$..book[?(@.isbn)]");
//All books in store cheaper than 10:获取json中book数组中price<10的所有值
List<Object> authors12 = JsonPath.read(json, "$.store.book[?(@.price < 10)]");
//All books in store that are not "expensive":获取json中book数组中price<=expensive的所有值
List<Object> authors13 = JsonPath.read(json, "$..book[?(@.price <= $.expensive)]");
//All books matching regex (ignore case):获取json中book数组中的作者以REES结尾的所有值(REES不区分大小写)
List<Object> authors14 = JsonPath.read(json, "$..book[?(@.author =~ /.*REES/i)]");
//Give me every thing:逐层列出json中的所有值,层级由外到内
List<Object> authors15 = JsonPath.read(json, "$..*");
//The number of books:获取json中book数组的长度
Integer authors16 = JsonPath.read(json, "$..book.length()");
print("**********authors1**********");
print(authors1);
print("**********authors2**********");
print(authors2);
print("**********authors3**********");
printOb(authors3);
print("**********authors4**********");
printOb(authors4);
print("**********authors5**********");
printOb(authors5);
print("**********authors6**********");
printOb(authors6);
print("**********authors7**********");
printOb(authors7);
print("**********authors8**********");
printOb(authors8);
print("**********authors9**********");
printOb(authors9);
print("**********authors10**********");
printOb(authors10);
print("**********authors11**********");
printOb(authors11);
print("**********authors12**********");
printOb(authors12);
print("**********authors13**********");
printOb(authors13);
print("**********authors14**********");
printOb(authors14);
print("**********authors15**********");
printOb(authors15);
print("**********authors16**********");
System.out.println(authors16);
print("************end**************");
}
private static void print(List<String> list) {
for(Iterator<String> it = list.iterator();it.hasNext();) {
System.out.println(it.next());
}
}
private static void printOb(List<Object> list) {
for(Iterator<Object> it = list.iterator();it.hasNext();) {
System.out.println(it.next());
}
}
private static void print(String s) {
System.out.println("\n"+s);
}
}

@ -0,0 +1,148 @@
package cc.bnblogs.springdatajpa.utils.custom;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.io.file.FileReader;
import cn.hutool.core.io.file.FileWriter;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
/**
* 将markdown文件中的所有本地图片转移到指定路径
* 跳过所有图床链接
* @author barney
*/
@Slf4j
public class MarkdownFileUtils {
/**
* 匹配markdown文件中图片的正则表达式 元组1中为图片描述元组2中为图片地址 ![描述信息](图片的真实地址)
*/
private static final String REGEX_IMG = "!\\[(.*?)\\]\\((.*?)\\)";
private static final String REGEX_IMG_BEGIN_WITH = "^https?.*$";
/**
* 移动本地markdown文件中的图片到指定目录
* 注意 重名图片会直接覆盖
*
* @param mdPath markdown 文件的路径
* @param targetImgDir 图片移动的目标文件夹
* @param onlyCopy 是否只是复制图片
*/
public static void moveImage(String mdPath, String targetImgDir, boolean onlyCopy) {
/// 先全部路径替换为 /分割 保证路径统一
String filePath = formatPath(mdPath);
targetImgDir = formatPath(targetImgDir);
// 通过设置的md文件路径取到相对路径 ,主要用于组装相对路径的图片真实路径
/// 切割出相对路径
String relativePath = filePath.substring(0, filePath.lastIndexOf("/") + 1);
FileReader fileReader = new FileReader(filePath);
// 从文件中读取内容为字符串
String readString = fileReader.readString();
// 最后覆盖输出的调整好的文件内容
// 编译正则表达式
Pattern patten = Pattern.compile(REGEX_IMG);
// 指定要匹配的字符串
Matcher matcher = patten.matcher(readString);
List<String> matchImagePaths = new ArrayList<>();
// 将匹配到的完整图片信息装入集合中, 此处find()每次被调用后,会偏移到下一个匹配
while (matcher.find()) {
matchImagePaths.add(matcher.group());
}
// 获取当前目录下的所有md文件中的所有图片链接, 这里$2取的时正则中第二个元组内包含的数据
Set<String> imagePaths = matchImagePaths.stream().map(v -> v.replaceAll(REGEX_IMG, "$2")).collect(Collectors.toSet());
log.info("读取到{}张图片地址,开始迁移图片", imagePaths.size());
int moveSuccess = 0;
int imageLink = 0;
int imageNotFound = 0;
int imageDuplicate = 0;
for (String imgPath : imagePaths) {
// 如果是图片外链,则跳过
if (Pattern.matches(REGEX_IMG_BEGIN_WITH,imgPath)) {
imageLink++;
continue;
}
if (!foundFile(imgPath)) {
imageNotFound++;
continue;
}
// 这里用一个新的变量来存真正的img地址,imgPath保留原值,用于后续替换地址
String realImagePath = formatPath(imgPath);
// 分别通过绝对路径和相对路径创建图片
if (!FileUtil.exist(realImagePath)) {
// 走绝对路径不存在,说明是相对路径,此时用文件的路径进行拼接
realImagePath = relativePath + realImagePath;
}
if (FileUtil.exist(realImagePath)) {
// 将图片复制到对应地址
String targetImgPath = targetImgDir + realImagePath.substring(realImagePath.lastIndexOf("/"));
// 目标地址已有该文件,跳过
if (foundFile(targetImgPath)) {
log.info("目标文件已存在,跳过...");
imageDuplicate++;
continue;
}
log.info("原图片:{} 即将迁移到:{}", realImagePath, targetImgPath);
// 待处理图片路径与原路径不一样时才处理
if (!StrUtil.equals(imgPath, targetImgPath)) {
// 复制或者移动图片
if (onlyCopy) {
FileUtil.copy(new File(realImagePath), new File(targetImgPath), true);
} else {
FileUtil.move(new File(realImagePath), new File(targetImgPath), true);
}
// 原文件中所有该 原路径图片地址,替换为目标图片路径
readString = readString.replace(imgPath, targetImgPath);
moveSuccess++;
}
}
}
// 文件写入
FileWriter fileWriter = new FileWriter(filePath);
fileWriter.write(readString);
log.info("===========================");
log.info("文件写入完毕!!");
log.info("目标文件夹已存在{}张相同图片",imageDuplicate);
log.info("共{}张图片已失效", imageNotFound);
log.info("共读取到{}张图片外链", imageLink);
log.info("成功移动{}张图片", moveSuccess);
}
/**
* 格式化路径 \ 反斜杠 全部替换为 / 正斜杠
*/
public static String formatPath(String path) {
return path.replaceAll("\\\\", "/");
}
public static boolean foundFile(String path) {
File file = new File(path);
return file.exists();
}
public static void main(String[] args) {
// 需要调整图片位置的md文件
String filePath = "D:\\desktop\\images\\git笔记.md";
// 移动图片到目标目录
String targetImgDir = "D:\\desktop\\images\\all";
moveImage(filePath, targetImgDir, true);
}
}

@ -0,0 +1,129 @@
package cc.bnblogs.springdatajpa.utils.custom;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.ReadContext;
import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class TestJsonPath3 {
public static void main(String[] args) {
String myJson = readJson();
print("-----------------------getJsonValue0-----------------------");
getJsonValue0(myJson);
print("-----------------------getJsonValue1-----------------------");
getJsonValue1(myJson);
print("-----------------------getJsonValue2-----------------------");
getJsonValue2(myJson);
print("-----------------------getJsonValue3-----------------------");
getJsonValue3(myJson);
print("-----------------------getJsonValue4-----------------------");
getJsonValue4(myJson);
}
private static String readJson() {
StringBuilder sb = new StringBuilder();
try {
FileReader fr = new FileReader("src/main/resources/static/data.json");
BufferedReader bfd = new BufferedReader(fr);
String s = "";
while ((s = bfd.readLine()) != null) {
sb.append(s);
}
} catch (Exception e) {
e.printStackTrace();
}
System.out.println(sb);
return sb.toString();
}
/**
* 读取json的一种写法得到匹配表达式的所有值
*/
private static void getJsonValue0(String json) {
List<String> authors = JsonPath.read(json, "$.store.book[*].author");
print(authors);
}
/**
* 读取JSON得到某个具体值推荐使用这种方法一次解析多次调用
*/
private static void getJsonValue1(String json) {
Object document = Configuration.defaultConfiguration().jsonProvider().parse(json);
String author0 = JsonPath.read(document, "$.store.book[0].author");
String author1 = JsonPath.read(document, "$.store.book[1].author");
print(author0);
print(author1);
}
/**
* 读取json的一种写法
*/
private static void getJsonValue2(String json) {
ReadContext ctx = JsonPath.parse(json);
// 获取json中book数组中包含isbn的作者
List<String> authorsOfBooksWithISBN = ctx.read("$.store.book[?(@.isbn)].author");
// 获取json中book数组中价格大于10的对象
List<Map<String, Object>> expensiveBooks = JsonPath
.using(Configuration.defaultConfiguration())
.parse(json)
.read("$.store.book[?(@.price > 10)]", List.class);
print(authorsOfBooksWithISBN);
print("********Map********");
printListMap(expensiveBooks);
}
/**
* 读取JSON得到的值是一个String所以不能用List存储
*/
private static void getJsonValue3(String json) {
//Will throw an java.lang.ClassCastException
//List<String> list = JsonPath.parse(json).read("$.store.book[0].author");
//由于会抛异常,暂时注释上面一行,要用的话,应使用下面的格式
String author = JsonPath.parse(json).read("$.store.book[0].author");
print(author);
}
/**
* 读取json的一种写法支持逻辑表达式&&||
*/
private static void getJsonValue4(String json) {
List<Map<String, Object>> books1 = JsonPath.parse(json).read("$.store.book[?(@.price < 10 && @.category == 'fiction')]");
List<Map<String, Object>> books2 = JsonPath.parse(json).read("$.store.book[?(@.category == 'reference' || @.price > 10)]");
print("********books1********");
printListMap(books1);
print("********books2********");
printListMap(books2);
}
private static void print(List<String> list) {
for (Iterator<String> it = list.iterator(); it.hasNext(); ) {
System.out.println(it.next());
}
// System.out.println(list);
}
private static void printListMap(List<Map<String, Object>> list) {
for (Iterator<Map<String, Object>> it = list.iterator(); it.hasNext(); ) {
Map<String, Object> map = it.next();
for (Iterator iterator = map.entrySet().iterator(); iterator.hasNext(); ) {
System.out.println(iterator.next());
}
}
// System.out.println(list);
}
private static void print(String s) {
System.out.println("\n" + s);
}
}

@ -11,3 +11,10 @@ spring:
ddl-auto: update
server:
port: 8080
logging:
file:
name: logs/spring-info.log
level:
root: info
# cc.bnblogs.springdatajpa.controller: info

@ -0,0 +1,37 @@
{
"store": {
"book": [
{
"category": "reference",
"author": "Nigel Rees",
"title": "Sayings of the Century",
"price": 8.95
},
{
"category": "fiction",
"author": "Evelyn Waugh",
"title": "Sword of Honour",
"price": 12.99
},
{
"category": "fiction",
"author": "Herman Melville",
"title": "Moby Dick",
"isbn": "0-553-21311-3",
"price": 8.99
},
{
"category": "fiction",
"author": "J. R. R. Tolkien",
"title": "The Lord of the Rings",
"isbn": "0-395-19395-8",
"price": 22.99
}
],
"bicycle": {
"color": "red",
"price": 19.95
}
},
"expensive": 10
}

@ -1,13 +1,19 @@
package cc.bnblogs.springdatajpa;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
/**
* 打印不同类型的日志
*/
@SpringBootTest
@Slf4j
class SpringDataJpaApplicationTests {
@Test
void contextLoads() {
}
}

@ -0,0 +1,82 @@
package cc.bnblogs.springdatajpa.utils.custom;
import com.jayway.jsonpath.Configuration;
import com.jayway.jsonpath.JsonPath;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
/**
* @description:
* @author: zfp@bnblogs.cc
* @date: 2023/3/9 16:19
*/
@SpringBootTest
class JsonPathStudyTest {
public static final String JSONSTRING = "{\n" +
" \"store\": {\n" +
" \"book\": [\n" +
" {\n" +
" \"category\": \"reference\",\n" +
" \"author\": \"Nigel Rees\",\n" +
" \"title\": \"Sayings of the Century\",\n" +
" \"price\": 8.95\n" +
" },\n" +
" {\n" +
" \"category\": \"fiction\",\n" +
" \"author\": \"Evelyn Waugh\",\n" +
" \"title\": \"Sword of Honour\",\n" +
" \"price\": 12.99\n" +
" },\n" +
" {\n" +
" \"category\": \"fiction\",\n" +
" \"author\": \"Herman Melville\",\n" +
" \"title\": \"Moby Dick\",\n" +
" \"isbn\": \"0-553-21311-3\",\n" +
" \"price\": 8.99\n" +
" },\n" +
" {\n" +
" \"category\": \"fiction\",\n" +
" \"author\": \"J. R. R. Tolkien\",\n" +
" \"title\": \"The Lord of the Rings\",\n" +
" \"isbn\": \"0-395-19395-8\",\n" +
" \"price\": 22.99\n" +
" }\n" +
" ],\n" +
" \"bicycle\": {\n" +
" \"color\": \"red\",\n" +
" \"price\": 19.95\n" +
" }\n" +
" },\n" +
" \"expensive\": 10\n" +
"}";
@Test
void demo() {
// 读取任意位置的元素
// List<String> bicycle= JsonPath.read(JSONSTRING, "$..book[?(@.price <= $.expensive)]");
Object document = Configuration.defaultConfiguration().jsonProvider().parse(JSONSTRING);
// String author0 = JsonPath.read(document, "$.store.book[0].author");
// String author1 = JsonPath.read(document, "$.store.book[1].author");
String str= JsonPath.read(document,"$['store']['bicycle']['color']");
System.out.println(str);
// // 读取所有authors
// List<String> authors = JsonPath.read(JSONSTRING, "$.store.book[*].author");
// authors.forEach(System.out::println);
// // 读取第一个和第二个author
// Object document = Configuration.defaultConfiguration().jsonProvider().parse(JSONSTRING);
//
// String author0 = JsonPath.read(document, "$.store.book[0].author");
// String author1 = JsonPath.read(document, "$.store.book[1].author");
//
// System.out.println(author0 + " " + author1);
}
}

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

@ -0,0 +1,18 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.8.7/apache-maven-3.8.7-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.1/maven-wrapper-3.1.1.jar

@ -0,0 +1,316 @@
#!/bin/sh
# ----------------------------------------------------------------------------
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
# ----------------------------------------------------------------------------
# ----------------------------------------------------------------------------
# Maven Start Up Batch script
#
# Required ENV vars:
# ------------------
# JAVA_HOME - location of a JDK home dir
#
# Optional ENV vars
# -----------------
# M2_HOME - location of maven2's installed home dir
# MAVEN_OPTS - parameters passed to the Java VM when running Maven
# e.g. to debug Maven itself, use
# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
# MAVEN_SKIP_RC - flag to disable loading of mavenrc files
# ----------------------------------------------------------------------------
if [ -z "$MAVEN_SKIP_RC" ] ; then
if [ -f /usr/local/etc/mavenrc ] ; then
. /usr/local/etc/mavenrc
fi
if [ -f /etc/mavenrc ] ; then
. /etc/mavenrc
fi
if [ -f "$HOME/.mavenrc" ] ; then
. "$HOME/.mavenrc"
fi
fi
# OS specific support. $var _must_ be set to either true or false.
cygwin=false;
darwin=false;
mingw=false
case "`uname`" in
CYGWIN*) cygwin=true ;;
MINGW*) mingw=true;;
Darwin*) darwin=true
# Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home
# See https://developer.apple.com/library/mac/qa/qa1170/_index.html
if [ -z "$JAVA_HOME" ]; then
if [ -x "/usr/libexec/java_home" ]; then
export JAVA_HOME="`/usr/libexec/java_home`"
else
export JAVA_HOME="/Library/Java/Home"
fi
fi
;;
esac
if [ -z "$JAVA_HOME" ] ; then
if [ -r /etc/gentoo-release ] ; then
JAVA_HOME=`java-config --jre-home`
fi
fi
if [ -z "$M2_HOME" ] ; then
## resolve links - $0 may be a link to maven's home
PRG="$0"
# need this for relative symlinks
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG="`dirname "$PRG"`/$link"
fi
done
saveddir=`pwd`
M2_HOME=`dirname "$PRG"`/..
# make it fully qualified
M2_HOME=`cd "$M2_HOME" && pwd`
cd "$saveddir"
# echo Using m2 at $M2_HOME
fi
# For Cygwin, ensure paths are in UNIX format before anything is touched
if $cygwin ; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --unix "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --unix "$CLASSPATH"`
fi
# For Mingw, ensure paths are in UNIX format before anything is touched
if $mingw ; then
[ -n "$M2_HOME" ] &&
M2_HOME="`(cd "$M2_HOME"; pwd)`"
[ -n "$JAVA_HOME" ] &&
JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`"
fi
if [ -z "$JAVA_HOME" ]; then
javaExecutable="`which javac`"
if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then
# readlink(1) is not available as standard on Solaris 10.
readLink=`which readlink`
if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then
if $darwin ; then
javaHome="`dirname \"$javaExecutable\"`"
javaExecutable="`cd \"$javaHome\" && pwd -P`/javac"
else
javaExecutable="`readlink -f \"$javaExecutable\"`"
fi
javaHome="`dirname \"$javaExecutable\"`"
javaHome=`expr "$javaHome" : '\(.*\)/bin'`
JAVA_HOME="$javaHome"
export JAVA_HOME
fi
fi
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
else
JAVACMD="`\\unset -f command; \\command -v java`"
fi
fi
if [ ! -x "$JAVACMD" ] ; then
echo "Error: JAVA_HOME is not defined correctly." >&2
echo " We cannot execute $JAVACMD" >&2
exit 1
fi
if [ -z "$JAVA_HOME" ] ; then
echo "Warning: JAVA_HOME environment variable is not set."
fi
CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher
# traverses directory structure from process work directory to filesystem root
# first directory with .mvn subdirectory is considered project base directory
find_maven_basedir() {
if [ -z "$1" ]
then
echo "Path not specified to find_maven_basedir"
return 1
fi
basedir="$1"
wdir="$1"
while [ "$wdir" != '/' ] ; do
if [ -d "$wdir"/.mvn ] ; then
basedir=$wdir
break
fi
# workaround for JBEAP-8937 (on Solaris 10/Sparc)
if [ -d "${wdir}" ]; then
wdir=`cd "$wdir/.."; pwd`
fi
# end of workaround
done
echo "${basedir}"
}
# concatenates all lines of a file
concat_lines() {
if [ -f "$1" ]; then
echo "$(tr -s '\n' ' ' < "$1")"
fi
}
BASE_DIR=`find_maven_basedir "$(pwd)"`
if [ -z "$BASE_DIR" ]; then
exit 1;
fi
##########################################################################################
# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
# This allows using the maven wrapper in projects that prohibit checking in binary data.
##########################################################################################
if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found .mvn/wrapper/maven-wrapper.jar"
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..."
fi
if [ -n "$MVNW_REPOURL" ]; then
jarUrl="$MVNW_REPOURL/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
else
jarUrl="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
fi
while IFS="=" read key value; do
case "$key" in (wrapperUrl) jarUrl="$value"; break ;;
esac
done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties"
if [ "$MVNW_VERBOSE" = true ]; then
echo "Downloading from: $jarUrl"
fi
wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar"
if $cygwin; then
wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"`
fi
if command -v wget > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found wget ... using wget"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
wget "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
else
wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" || rm -f "$wrapperJarPath"
fi
elif command -v curl > /dev/null; then
if [ "$MVNW_VERBOSE" = true ]; then
echo "Found curl ... using curl"
fi
if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then
curl -o "$wrapperJarPath" "$jarUrl" -f
else
curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f
fi
else
if [ "$MVNW_VERBOSE" = true ]; then
echo "Falling back to using Java to download"
fi
javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java"
# For Cygwin, switch paths to Windows format before running javac
if $cygwin; then
javaClass=`cygpath --path --windows "$javaClass"`
fi
if [ -e "$javaClass" ]; then
if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Compiling MavenWrapperDownloader.java ..."
fi
# Compiling the Java class
("$JAVA_HOME/bin/javac" "$javaClass")
fi
if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then
# Running the downloader
if [ "$MVNW_VERBOSE" = true ]; then
echo " - Running MavenWrapperDownloader.java ..."
fi
("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR")
fi
fi
fi
fi
##########################################################################################
# End of extension
##########################################################################################
export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"}
if [ "$MVNW_VERBOSE" = true ]; then
echo $MAVEN_PROJECTBASEDIR
fi
MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS"
# For Cygwin, switch paths to Windows format before running java
if $cygwin; then
[ -n "$M2_HOME" ] &&
M2_HOME=`cygpath --path --windows "$M2_HOME"`
[ -n "$JAVA_HOME" ] &&
JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"`
[ -n "$CLASSPATH" ] &&
CLASSPATH=`cygpath --path --windows "$CLASSPATH"`
[ -n "$MAVEN_PROJECTBASEDIR" ] &&
MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"`
fi
# Provide a "standardized" way to retrieve the CLI args that will
# work with both Windows and non-Windows executions.
MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@"
export MAVEN_CMD_LINE_ARGS
WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
exec "$JAVACMD" \
$MAVEN_OPTS \
$MAVEN_DEBUG_OPTS \
-classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \
"-Dmaven.home=${M2_HOME}" \
"-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \
${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@"

@ -0,0 +1,188 @@
@REM ----------------------------------------------------------------------------
@REM Licensed to the Apache Software Foundation (ASF) under one
@REM or more contributor license agreements. See the NOTICE file
@REM distributed with this work for additional information
@REM regarding copyright ownership. The ASF licenses this file
@REM to you under the Apache License, Version 2.0 (the
@REM "License"); you may not use this file except in compliance
@REM with the License. You may obtain a copy of the License at
@REM
@REM https://www.apache.org/licenses/LICENSE-2.0
@REM
@REM Unless required by applicable law or agreed to in writing,
@REM software distributed under the License is distributed on an
@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@REM KIND, either express or implied. See the License for the
@REM specific language governing permissions and limitations
@REM under the License.
@REM ----------------------------------------------------------------------------
@REM ----------------------------------------------------------------------------
@REM Maven Start Up Batch script
@REM
@REM Required ENV vars:
@REM JAVA_HOME - location of a JDK home dir
@REM
@REM Optional ENV vars
@REM M2_HOME - location of maven2's installed home dir
@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands
@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending
@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven
@REM e.g. to debug Maven itself, use
@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000
@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files
@REM ----------------------------------------------------------------------------
@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on'
@echo off
@REM set title of command window
title %0
@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on'
@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO%
@REM set %HOME% to equivalent of $HOME
if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%")
@REM Execute a user defined script before this one
if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre
@REM check for pre script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_pre.bat" call "%USERPROFILE%\mavenrc_pre.bat" %*
if exist "%USERPROFILE%\mavenrc_pre.cmd" call "%USERPROFILE%\mavenrc_pre.cmd" %*
:skipRcPre
@setlocal
set ERROR_CODE=0
@REM To isolate internal variables from possible post scripts, we use another setlocal
@setlocal
@REM ==== START VALIDATION ====
if not "%JAVA_HOME%" == "" goto OkJHome
echo.
echo Error: JAVA_HOME not found in your environment. >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
:OkJHome
if exist "%JAVA_HOME%\bin\java.exe" goto init
echo.
echo Error: JAVA_HOME is set to an invalid directory. >&2
echo JAVA_HOME = "%JAVA_HOME%" >&2
echo Please set the JAVA_HOME variable in your environment to match the >&2
echo location of your Java installation. >&2
echo.
goto error
@REM ==== END VALIDATION ====
:init
@REM Find the project base dir, i.e. the directory that contains the folder ".mvn".
@REM Fallback to current working directory if not found.
set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR%
IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir
set EXEC_DIR=%CD%
set WDIR=%EXEC_DIR%
:findBaseDir
IF EXIST "%WDIR%"\.mvn goto baseDirFound
cd ..
IF "%WDIR%"=="%CD%" goto baseDirNotFound
set WDIR=%CD%
goto findBaseDir
:baseDirFound
set MAVEN_PROJECTBASEDIR=%WDIR%
cd "%EXEC_DIR%"
goto endDetectBaseDir
:baseDirNotFound
set MAVEN_PROJECTBASEDIR=%EXEC_DIR%
cd "%EXEC_DIR%"
:endDetectBaseDir
IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig
@setlocal EnableExtensions EnableDelayedExpansion
for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a
@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS%
:endReadAdditionalConfig
SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe"
set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar"
set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain
set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
FOR /F "usebackq tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO (
IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B
)
@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central
@REM This allows using the maven wrapper in projects that prohibit checking in binary data.
if exist %WRAPPER_JAR% (
if "%MVNW_VERBOSE%" == "true" (
echo Found %WRAPPER_JAR%
)
) else (
if not "%MVNW_REPOURL%" == "" (
SET DOWNLOAD_URL="%MVNW_REPOURL%/org/apache/maven/wrapper/maven-wrapper/3.1.0/maven-wrapper-3.1.0.jar"
)
if "%MVNW_VERBOSE%" == "true" (
echo Couldn't find %WRAPPER_JAR%, downloading it ...
echo Downloading from: %DOWNLOAD_URL%
)
powershell -Command "&{"^
"$webclient = new-object System.Net.WebClient;"^
"if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^
"$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^
"}"^
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^
"}"
if "%MVNW_VERBOSE%" == "true" (
echo Finished downloading %WRAPPER_JAR%
)
)
@REM End of extension
@REM Provide a "standardized" way to retrieve the CLI args that will
@REM work with both Windows and non-Windows executions.
set MAVEN_CMD_LINE_ARGS=%*
%MAVEN_JAVA_EXE% ^
%JVM_CONFIG_MAVEN_PROPS% ^
%MAVEN_OPTS% ^
%MAVEN_DEBUG_OPTS% ^
-classpath %WRAPPER_JAR% ^
"-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" ^
%WRAPPER_LAUNCHER% %MAVEN_CONFIG% %*
if ERRORLEVEL 1 goto error
goto end
:error
set ERROR_CODE=1
:end
@endlocal & set ERROR_CODE=%ERROR_CODE%
if not "%MAVEN_SKIP_RC%"=="" goto skipRcPost
@REM check for post script, once with legacy .bat ending and once with .cmd ending
if exist "%USERPROFILE%\mavenrc_post.bat" call "%USERPROFILE%\mavenrc_post.bat"
if exist "%USERPROFILE%\mavenrc_post.cmd" call "%USERPROFILE%\mavenrc_post.cmd"
:skipRcPost
@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on'
if "%MAVEN_BATCH_PAUSE%"=="on" pause
if "%MAVEN_TERMINATE_CMD%"=="on" exit %ERROR_CODE%
cmd /C exit /B %ERROR_CODE%

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.7.9</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>cc.bnblogs</groupId>
<artifactId>mybatis_study</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mybatis_study</name>
<description>mybatis_study</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.1</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.5.3.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>3.0.3</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<excludes>
<exclude>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,11 @@
spring.datasource.username=root
spring.datasource.password=zfp251217
spring.datasource.url=jdbc:mysql://192.168.153.131:3306/study?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
# logging
# method-1
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl
# method-2
# \u540C\u65F6\u914D\u7F6E\u4E24\u4E2A\u5C06\u663E\u793A\u65B9\u6CD5\u4E00\u7684\u914D\u7F6E\u5185\u5BB9
logging.level.cc.bnblogs.mybatis_study.mapper=debug

@ -9,10 +9,10 @@
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>cc.bnblogs</groupId>
<artifactId>mybatis_study</artifactId>
<artifactId>newDemo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>mybatis_study</name>
<description>mybatis_study</description>
<name>MyBatis</name>
<description>MyBatis</description>
<properties>
<java.version>1.8</java.version>
</properties>
@ -28,18 +28,11 @@
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
@ -47,23 +40,28 @@
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.5.3.1</version>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.5.3.1</version>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>1.2.11</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
<version>3.0.3</version>
<groupId>com.mysql</groupId>
<artifactId>mysql-connector-j</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
</dependency>
</dependencies>
<build>

@ -0,0 +1,21 @@
package cc.bnblogs.newdemo;
import cc.bnblogs.newdemo.bean.ConfigBean;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.ServletComponentScan;
@SpringBootApplication
@ServletComponentScan
@EnableConfigurationProperties({ConfigBean.class})
public class NewDemoApplication {
public static void main(String[] args) {
// SpringApplication app = new SpringApplication(NewDemoApplication.class);
// app.setBannerMode(Banner.Mode.OFF);
// app.run(args);
SpringApplication.run(NewDemoApplication.class,args);
}
}

@ -0,0 +1,19 @@
package cc.bnblogs.newdemo.bean;
import lombok.Data;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
@Component
@Data
public class BlogProperties {
@Value("${barney.blog.name}")
private String name;
@Value("${barney.blog.title}")
private String title;
@Value("${barney.blog.webtitle}")
private String webTitle;
}

@ -0,0 +1,17 @@
package cc.bnblogs.newdemo.bean;
import org.springframework.boot.context.properties.ConfigurationProperties;
/**
* @description: 通用前缀加属性名和配置文件的属性名一一对应
* @author: zfp@bnblogs.cc
* @date: 2023/3/17 21:05
*/
//@Component
@ConfigurationProperties(prefix = "barney.blog")
public class ConfigBean {
private String name;
private String title;
private String webtitle;
}

@ -0,0 +1,19 @@
package cc.bnblogs.newdemo.bean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;
/**
* 前缀不能重复
*/
@Configuration
@ConfigurationProperties(prefix="barneys.blog")
@PropertySource("classpath:blog.properties")
@Component
public class TestConfigBean {
private String name;
private String age;
private String webtitle;
}

@ -0,0 +1,34 @@
package cc.bnblogs.newdemo.controller;
import cc.bnblogs.newdemo.mapper.BlogInfoMapper;
import cc.bnblogs.newdemo.pojo.BlogInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* @description:
* @author: zfp@bnblogs.cc
* @date: 2023/3/18 16:29
*/
@RestController
@RequestMapping("/blog")
public class BlogInfoController {
@Autowired
private BlogInfoMapper blogMapper;
@GetMapping("/all")
public List<BlogInfo> getAllBlog() {
return blogMapper.getAllBlogInfo();
}
@PostMapping("/add")
public int addBlog(@RequestBody BlogInfo blogInfo) {
return blogMapper.addBlog(blogInfo);
}
@PostMapping("/update")
public int updateBlogInfo(@RequestBody BlogInfo blogInfo) {
return blogMapper.updateBlogInfo(blogInfo);
}
}

@ -0,0 +1,17 @@
package cc.bnblogs.newdemo.controller;
import cc.bnblogs.newdemo.bean.BlogProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class IndexController {
@Autowired
private BlogProperties blogProperties;
@RequestMapping("/")
public String index() {
return blogProperties.getWebTitle();
}
}

@ -0,0 +1,57 @@
package cc.bnblogs.newdemo.controller;
import cc.bnblogs.newdemo.mapper.UserMapper;
import cc.bnblogs.newdemo.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: zfp@bnblogs.cc
* @date: 2023/3/17 23:17
*/
@RestController
@RequestMapping("/user")
public class UserController {
@Autowired
private UserMapper userMapper;
@GetMapping("/all")
public List<User> getAllUser() {
return userMapper.queryAllUser();
}
@PostMapping
public User getUserById(@RequestBody Integer id) {
return userMapper.queryUserById(id);
}
@PostMapping("/add")
public int addUser(@RequestBody User user){
return userMapper.addUser(user);
}
@DeleteMapping("/delete")
public int deleteUser(@RequestBody Integer id){
return userMapper.deleteById(id);
}
@PostMapping("/update/part")
public int updateUserName(@RequestParam Integer id,
@RequestParam String name) {
return userMapper.updateUserNameById(id,name);
}
@GetMapping("/info")
public List<Map<String,Object>> getPartInfo() {
return userMapper.getPartInfo();
}
@PostMapping("/update/all")
public int updateUserInfo(@RequestBody User user) {
return userMapper.updateUser(user);
}
}

@ -0,0 +1,24 @@
package cc.bnblogs.newdemo.mapper;
import cc.bnblogs.newdemo.pojo.BlogInfo;
import org.apache.ibatis.annotations.*;
import java.util.List;
/**
* @description:
* @author: zfp@bnblogs.cc
* @date: 2023/3/18 16:28
*/
@Mapper
public interface BlogInfoMapper {
@Select("select id,blog_title,blog_author from blog_info")
List<BlogInfo> getAllBlogInfo();
@Insert("insert into blog_info(blog_title,blog_author) values(#{blogTitle},#{blogAuthor})")
@Options(useGeneratedKeys = true, keyProperty = "id")
int addBlog(BlogInfo blogInfo);
@Update("update blog_info set blog_title=#{blogTitle}, blog_author=#{blogAuthor} where id=#{id}")
int updateBlogInfo(BlogInfo blogInfo);
}

@ -0,0 +1,72 @@
package cc.bnblogs.newdemo.mapper;
import cc.bnblogs.newdemo.pojo.User;
import jdk.nashorn.internal.codegen.MapCreator;
import org.apache.ibatis.annotations.*;
import java.util.List;
import java.util.Map;
/**
* @description:
* @author: zfp@bnblogs.cc
* @date: 2023/3/17 23:09
*/
@Mapper
public interface UserMapper {
/**
* 返回所有用户数据
* @return
*/
// @Select(value = "select id,name,age,email from user")
List<User> queryAllUser();
/**
* 根据用户id返回对应用户的数据
* @return
*/
// @Select("select id,name,age,email from user where id=#{id}")
User queryUserById(Integer id);
/**
* 插入新的用户数据
* 设置id自增
* @param user 新用户
* @return
*/
// @Insert("insert into user(name,age,email) values(#{name},#{age},#{email})")
// @Options(useGeneratedKeys = true, keyProperty = "id")
int addUser(User user);
/**
* 删除用户
* @param id 删除的用户id
* @return
*/
// @Delete("delete from user where id=#{id}")
int deleteById(Integer id);
/**
* 更新用户名
* @param id 用户id
* @param newName 用户的新用户名
* @return
*/
// @Update("update user set name=#{newName} where id=#{id}")
// 不加@Param(key)也可以, 直接在xml中使用#{key}接收
int updateUserNameById(@Param("id") Integer id,@Param("newName") String newName);
/**
*更新用户所有信息
* @param user 新的用户数据
* @return
*/
// @Update("update user set name=#{name},age=#{age},email=#{email} where id=#{id}")
int updateUser(User user);
/**
* 返回用户的部分字段信息
* @return
*/
// @Select("select id,name,email from user")
List<Map<String,Object>> getPartInfo();
}

@ -0,0 +1,20 @@
package cc.bnblogs.newdemo.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @description:
* @author: zfp@bnblogs.cc
* @date: 2023/3/18 16:24
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
public class BlogInfo {
private int id;
private String blogAuthor;
private String blogTitle;
}

@ -0,0 +1,20 @@
package cc.bnblogs.newdemo.pojo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @description:
* @author: zfp@bnblogs.cc
* @date: 2023/3/17 23:04
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class User {
private Integer id;
private String name;
private Integer age;
private String email;
}

@ -1,4 +0,0 @@
spring.datasource.username=root
spring.datasource.password=zfp251217
spring.datasource.url=jdbc:mysql://192.168.153.131:3306/study?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

@ -0,0 +1,68 @@
barney:
blog:
name: Barney's Blog
title: SpringBoot
webtitle: ${barney.blog.name}--${barney.blog.title}
server:
port: 8080
#spring:
# profiles:
# active: prod
Spring:
# 配置MySQL
datasource:
username: root
password: zfp251217
url: jdbc:mysql://192.168.153.135:3306/test?serverTimezone=Asia/Shanghai&useUnicode=true&characterEncoding=utf-8
driver-class-name: com.mysql.cj.jdbc.Driver
druid:
# 连接池配置
initial-size: 10
min-idle: 10
maxActive: 200
maxWait: 60000
# 检测可以关闭的空闲连接间隔时间
timeBetweenEvictionRunsMillis: 60000
minEvictableIdleTimeMillis: 300000
validationQuery: SELECT 1 FROM DUAL
testWhileIdle: true
testOnBorrow: false
testOnReturn: false
# 打开PSCache,并且指定每个连接上PSCache的大小
poolPreparedStatements: true
maxPoolPreparedStatementPerConnectionSize: 20
connectionErrorRetryAttempts: 3
breakAfterAcquireFailure: true
timeBetweenConnectErrorMillis: 300000
asyncInit: true
remove-abandoned: true
remove-abandoned-timeout: 1800
transaction-query-timeout: 6000
# 配置监控统计拦截的filters, 去掉后监控界面sql无法统计, wall用于防火墙
filters: stat,wall,log4j2
connectionProperties: druid.stat.mergeSql\=true;druid.stat.slowSqlMillis\=5000
# WebStatFilter配置
web-stat-filter:
enabled: true
# 添加过滤规则
url-pattern: "/*"
# 忽略过滤的格式
exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
# 配置监控
stat-view-servlet:
enabled: true
url-pattern: "/druid/*" # 访问路径为/druid时,跳转到StatViewServlet
allow: # ip 白名单
deny: # ip 黑名单 (共同存在时,deny优先于allow)
reset-enable: false # 是否能够重置数据
login-username: admin # 需要账户名和密码才能访问控制台
login-password: admin123
mybatis:
configuration:
map-underscore-to-camel-case: true
# type-aliases扫描路径
type-aliases-package: cc.bnblogs.newdemo.pojo
# mapper xml实现扫描路径
mapper-locations: classpath:mapper/*.xml

@ -0,0 +1,9 @@
博客地址: https://hugo.bnblogs.cc
_ _ _
| | | | | |
| |__ _ __ | |__ | | ___ __ _ ___
| '_ \| '_ \| '_ \| |/ _ \ / _` / __|
| |_) | | | | |_) | | (_) | (_| \__ \
|_.__/|_| |_|_.__/|_|\___/ \__, |___/
__/ |
|___/

@ -0,0 +1,3 @@
barneys.blog.name=Barney's Blog
barneys.blog.title=SpringBoot
barneys.blog.webtitle=${barney.blog.name}--${barney.blog.title}

@ -0,0 +1,61 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<!--namespace为mapper类的全路径-->
<mapper namespace="cc.bnblogs.newdemo.mapper.UserMapper">
<!--id为唯一表示,type为实体类全路径-->
<resultMap id="BaseResultMap" type="cc.bnblogs.newdemo.pojo.User">
<!--主键和其他属性-->
<!--property为实体类属性名,column为数据库列名 -->
<id property="id" column="id" jdbcType="INTEGER"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="age" column="age" jdbcType="INTEGER"/>
<result property="email" column="email" jdbcType="VARCHAR"/>
</resultMap>
<!--id的值必须和数据处理层的接口名一致-->
<!--此处的User-->
<select id="queryAllUser" resultType="User">
select * from user
</select>
<insert id="addUser">
insert into user(id,name,age,email) values(#{id},#{name},#{age},#{email})
</insert>
<update id="updateUserNameById">
update user set name=#{newName} where id = #{id}
</update>
<update id="updateUser">
update user set name=#{name},age=#{age},email=#{email} where id=#{id}
</update>
<!--
在删除数据的时候,自动会返回受影响的行数,
不需要在delete节点中定义返回类型,
只有在查询数据的时候才会定义返回类型-->
<!-- 删除用户数据根据id
Integer deleteUserById(int id)
parameterType: 指定参数类型,这里也可以不需要指定
-->
<delete id="deleteById">
delete from user where id=#{id}
</delete>
<select id="queryUserById" resultType="User">
select * from user where id=#{id}
</select>
<select id="getPartInfo" resultType="java.util.Map">
select id, name,age from user
</select>
</mapper>

@ -0,0 +1,13 @@
package cc.bnblogs.newdemo;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class NewDemoApplicationTests {
@Test
void contextLoads() {
}
}
Loading…
Cancel
Save