Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
MybatisTraning
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
CI / CD
CI / CD
Pipelines
Schedules
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
training
MybatisTraning
Commits
d80356de
Commit
d80356de
authored
Jan 02, 2020
by
happylin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
沈金奇作业提交
parent
3b75f7c0
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
621 additions
and
0 deletions
+621
-0
.name
沈金奇_Mybatis2/.idea/.name
+3
-0
compiler.xml
沈金奇_Mybatis2/.idea/compiler.xml
+18
-0
Maven__junit_junit_4_12.xml
沈金奇_Mybatis2/.idea/libraries/Maven__junit_junit_4_12.xml
+15
-0
Maven__log4j_log4j_1_2_17.xml
沈金奇_Mybatis2/.idea/libraries/Maven__log4j_log4j_1_2_17.xml
+15
-0
Maven__mysql_mysql_connector_java_5_1_32.xml
...ea/libraries/Maven__mysql_mysql_connector_java_5_1_32.xml
+15
-0
Maven__org_hamcrest_hamcrest_core_1_3.xml
....idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
+15
-0
Maven__org_mybatis_mybatis_3_4_6.xml
...tis2/.idea/libraries/Maven__org_mybatis_mybatis_3_4_6.xml
+15
-0
Maven__org_slf4j_slf4j_api_1_7_25.xml
...is2/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml
+15
-0
Maven__org_slf4j_slf4j_log4j12_1_7_25.xml
....idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_7_25.xml
+15
-0
misc.xml
沈金奇_Mybatis2/.idea/misc.xml
+15
-0
modules.xml
沈金奇_Mybatis2/.idea/modules.xml
+10
-0
uiDesigner.xml
沈金奇_Mybatis2/.idea/uiDesigner.xml
+126
-0
workspace.xml
沈金奇_Mybatis2/.idea/workspace.xml
+0
-0
pom.xml
沈金奇_Mybatis2/pom.xml
+66
-0
MybatisLogInterceptor.java
.../java/com/cesgroup/Interceptor/MybatisLogInterceptor.java
+74
-0
Student.java
沈金奇_Mybatis2/src/main/java/com/cesgroup/pojo/Student.java
+28
-0
ReflectHelper.java
...batis2/src/main/java/com/cesgroup/util/ReflectHelper.java
+36
-0
StudentMapper.xml
沈金奇_Mybatis2/src/main/resources/StudentMapper.xml
+9
-0
jdbc.properties
沈金奇_Mybatis2/src/main/resources/jdbc.properties
+6
-0
log4j.properties
沈金奇_Mybatis2/src/main/resources/log4j.properties
+10
-0
mybatis-config.xml
沈金奇_Mybatis2/src/main/resources/mybatis-config.xml
+35
-0
mybatis.sql
沈金奇_Mybatis2/src/main/resources/mybatis.sql
+15
-0
MybatisLogInterceptorTest.java
...a/com/cesgroup/Interceptor/MybatisLogInterceptorTest.java
+42
-0
沈金奇_Mybatis2.iml
沈金奇_Mybatis2/沈金奇_Mybatis2.iml
+23
-0
No files found.
沈金奇_Mybatis2/.idea/.name
0 → 100644
View file @
d80356de
林欢欢_Mybatis2
林欢欢_Mybatis2
\ No newline at end of file
沈金奇_Mybatis2/.idea/compiler.xml
0 → 100644
View file @
d80356de
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"CompilerConfiguration"
>
<annotationProcessing>
<profile
name=
"Maven default annotation processors profile"
enabled=
"true"
>
<sourceOutputDir
name=
"target/generated-sources/annotations"
/>
<sourceTestOutputDir
name=
"target/generated-test-sources/test-annotations"
/>
<outputRelativeToContentRoot
value=
"true"
/>
<module
name=
"林欢欢_Mybatis2"
/>
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module
name=
"林欢欢_Mybatis2"
target=
"1.8"
/>
</bytecodeTargetLevel>
</component>
</project>
\ No newline at end of file
沈金奇_Mybatis2/.idea/libraries/Maven__junit_junit_4_12.xml
0 → 100644
View file @
d80356de
<component
name=
"libraryTable"
>
<component
name=
"libraryTable"
>
<library
name=
"Maven: junit:junit:4.12"
>
<CLASSES>
<root
url=
"jar://$USER_HOME$/.m2/repository/junit/junit/4.12/junit-4.12.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://$USER_HOME$/.m2/repository/junit/junit/4.12/junit-4.12-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://$USER_HOME$/.m2/repository/junit/junit/4.12/junit-4.12-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
沈金奇_Mybatis2/.idea/libraries/Maven__log4j_log4j_1_2_17.xml
0 → 100644
View file @
d80356de
<component
name=
"libraryTable"
>
<component
name=
"libraryTable"
>
<library
name=
"Maven: log4j:log4j:1.2.17"
>
<CLASSES>
<root
url=
"jar://$USER_HOME$/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://$USER_HOME$/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://$USER_HOME$/.m2/repository/log4j/log4j/1.2.17/log4j-1.2.17-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
沈金奇_Mybatis2/.idea/libraries/Maven__mysql_mysql_connector_java_5_1_32.xml
0 → 100644
View file @
d80356de
<component
name=
"libraryTable"
>
<component
name=
"libraryTable"
>
<library
name=
"Maven: mysql:mysql-connector-java:5.1.32"
>
<CLASSES>
<root
url=
"jar://$USER_HOME$/.m2/repository/mysql/mysql-connector-java/5.1.32/mysql-connector-java-5.1.32.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://$USER_HOME$/.m2/repository/mysql/mysql-connector-java/5.1.32/mysql-connector-java-5.1.32-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://$USER_HOME$/.m2/repository/mysql/mysql-connector-java/5.1.32/mysql-connector-java-5.1.32-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
沈金奇_Mybatis2/.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_3.xml
0 → 100644
View file @
d80356de
<component
name=
"libraryTable"
>
<component
name=
"libraryTable"
>
<library
name=
"Maven: org.hamcrest:hamcrest-core:1.3"
>
<CLASSES>
<root
url=
"jar://$USER_HOME$/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://$USER_HOME$/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://$USER_HOME$/.m2/repository/org/hamcrest/hamcrest-core/1.3/hamcrest-core-1.3-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
沈金奇_Mybatis2/.idea/libraries/Maven__org_mybatis_mybatis_3_4_6.xml
0 → 100644
View file @
d80356de
<component
name=
"libraryTable"
>
<component
name=
"libraryTable"
>
<library
name=
"Maven: org.mybatis:mybatis:3.4.6"
>
<CLASSES>
<root
url=
"jar://$USER_HOME$/.m2/repository/org/mybatis/mybatis/3.4.6/mybatis-3.4.6.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://$USER_HOME$/.m2/repository/org/mybatis/mybatis/3.4.6/mybatis-3.4.6-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://$USER_HOME$/.m2/repository/org/mybatis/mybatis/3.4.6/mybatis-3.4.6-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
沈金奇_Mybatis2/.idea/libraries/Maven__org_slf4j_slf4j_api_1_7_25.xml
0 → 100644
View file @
d80356de
<component
name=
"libraryTable"
>
<component
name=
"libraryTable"
>
<library
name=
"Maven: org.slf4j:slf4j-api:1.7.25"
>
<CLASSES>
<root
url=
"jar://$USER_HOME$/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://$USER_HOME$/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://$USER_HOME$/.m2/repository/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
沈金奇_Mybatis2/.idea/libraries/Maven__org_slf4j_slf4j_log4j12_1_7_25.xml
0 → 100644
View file @
d80356de
<component
name=
"libraryTable"
>
<component
name=
"libraryTable"
>
<library
name=
"Maven: org.slf4j:slf4j-log4j12:1.7.25"
>
<CLASSES>
<root
url=
"jar://$USER_HOME$/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25.jar!/"
/>
</CLASSES>
<JAVADOC>
<root
url=
"jar://$USER_HOME$/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25-javadoc.jar!/"
/>
</JAVADOC>
<SOURCES>
<root
url=
"jar://$USER_HOME$/.m2/repository/org/slf4j/slf4j-log4j12/1.7.25/slf4j-log4j12-1.7.25-sources.jar!/"
/>
</SOURCES>
</library>
</component>
\ No newline at end of file
沈金奇_Mybatis2/.idea/misc.xml
0 → 100644
View file @
d80356de
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"MavenProjectsManager"
>
<option
name=
"originalFiles"
>
<list>
<option
value=
"$PROJECT_DIR$/pom.xml"
/>
</list>
</option>
</component>
<component
name=
"ProjectRootManager"
version=
"2"
languageLevel=
"JDK_1_8"
project-jdk-name=
"1.8"
project-jdk-type=
"JavaSDK"
>
<output
url=
"file://$PROJECT_DIR$/classes"
/>
</component>
</project>
\ No newline at end of file
沈金奇_Mybatis2/.idea/modules.xml
0 → 100644
View file @
d80356de
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"ProjectModuleManager"
>
<modules>
<module
fileurl=
"file://$PROJECT_DIR$/沈金奇_Mybatis2.iml"
filepath=
"$PROJECT_DIR$/沈金奇_Mybatis2.iml"
/>
</modules>
</component>
</project>
\ No newline at end of file
沈金奇_Mybatis2/.idea/uiDesigner.xml
0 → 100644
View file @
d80356de
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"Palette2"
>
<group
name=
"Swing"
>
<item
class=
"com.intellij.uiDesigner.HSpacer"
tooltip-text=
"Horizontal Spacer"
icon=
"/com/intellij/uiDesigner/icons/hspacer.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"1"
hsize-policy=
"6"
anchor=
"0"
fill=
"1"
/>
</item>
<item
class=
"com.intellij.uiDesigner.VSpacer"
tooltip-text=
"Vertical Spacer"
icon=
"/com/intellij/uiDesigner/icons/vspacer.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"1"
anchor=
"0"
fill=
"2"
/>
</item>
<item
class=
"javax.swing.JPanel"
icon=
"/com/intellij/uiDesigner/icons/panel.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"3"
hsize-policy=
"3"
anchor=
"0"
fill=
"3"
/>
</item>
<item
class=
"javax.swing.JScrollPane"
icon=
"/com/intellij/uiDesigner/icons/scrollPane.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"7"
hsize-policy=
"7"
anchor=
"0"
fill=
"3"
/>
</item>
<item
class=
"javax.swing.JButton"
icon=
"/com/intellij/uiDesigner/icons/button.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"3"
anchor=
"0"
fill=
"1"
/>
<initial-values>
<property
name=
"text"
value=
"Button"
/>
</initial-values>
</item>
<item
class=
"javax.swing.JRadioButton"
icon=
"/com/intellij/uiDesigner/icons/radioButton.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"3"
anchor=
"8"
fill=
"0"
/>
<initial-values>
<property
name=
"text"
value=
"RadioButton"
/>
</initial-values>
</item>
<item
class=
"javax.swing.JCheckBox"
icon=
"/com/intellij/uiDesigner/icons/checkBox.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"3"
anchor=
"8"
fill=
"0"
/>
<initial-values>
<property
name=
"text"
value=
"CheckBox"
/>
</initial-values>
</item>
<item
class=
"javax.swing.JLabel"
icon=
"/com/intellij/uiDesigner/icons/label.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"0"
anchor=
"8"
fill=
"0"
/>
<initial-values>
<property
name=
"text"
value=
"Label"
/>
</initial-values>
</item>
<item
class=
"javax.swing.JTextField"
icon=
"/com/intellij/uiDesigner/icons/textField.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
>
<preferred-size
width=
"150"
height=
"-1"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JPasswordField"
icon=
"/com/intellij/uiDesigner/icons/passwordField.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
>
<preferred-size
width=
"150"
height=
"-1"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JFormattedTextField"
icon=
"/com/intellij/uiDesigner/icons/formattedTextField.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
>
<preferred-size
width=
"150"
height=
"-1"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JTextArea"
icon=
"/com/intellij/uiDesigner/icons/textArea.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JTextPane"
icon=
"/com/intellij/uiDesigner/icons/textPane.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JEditorPane"
icon=
"/com/intellij/uiDesigner/icons/editorPane.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JComboBox"
icon=
"/com/intellij/uiDesigner/icons/comboBox.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"2"
anchor=
"8"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JTable"
icon=
"/com/intellij/uiDesigner/icons/table.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JList"
icon=
"/com/intellij/uiDesigner/icons/list.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"2"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JTree"
icon=
"/com/intellij/uiDesigner/icons/tree.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"150"
height=
"50"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JTabbedPane"
icon=
"/com/intellij/uiDesigner/icons/tabbedPane.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"3"
hsize-policy=
"3"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"200"
height=
"200"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JSplitPane"
icon=
"/com/intellij/uiDesigner/icons/splitPane.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"3"
hsize-policy=
"3"
anchor=
"0"
fill=
"3"
>
<preferred-size
width=
"200"
height=
"200"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JSpinner"
icon=
"/com/intellij/uiDesigner/icons/spinner.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"true"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JSlider"
icon=
"/com/intellij/uiDesigner/icons/slider.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"8"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JSeparator"
icon=
"/com/intellij/uiDesigner/icons/separator.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"6"
anchor=
"0"
fill=
"3"
/>
</item>
<item
class=
"javax.swing.JProgressBar"
icon=
"/com/intellij/uiDesigner/icons/progressbar.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"0"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JToolBar"
icon=
"/com/intellij/uiDesigner/icons/toolbar.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"6"
anchor=
"0"
fill=
"1"
>
<preferred-size
width=
"-1"
height=
"20"
/>
</default-constraints>
</item>
<item
class=
"javax.swing.JToolBar$Separator"
icon=
"/com/intellij/uiDesigner/icons/toolbarSeparator.png"
removable=
"false"
auto-create-binding=
"false"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"0"
hsize-policy=
"0"
anchor=
"0"
fill=
"1"
/>
</item>
<item
class=
"javax.swing.JScrollBar"
icon=
"/com/intellij/uiDesigner/icons/scrollbar.png"
removable=
"false"
auto-create-binding=
"true"
can-attach-label=
"false"
>
<default-constraints
vsize-policy=
"6"
hsize-policy=
"0"
anchor=
"0"
fill=
"2"
/>
</item>
</group>
</component>
</project>
\ No newline at end of file
沈金奇_Mybatis2/.idea/workspace.xml
0 → 100644
View file @
d80356de
This diff is collapsed.
Click to expand it.
沈金奇_Mybatis2/pom.xml
0 → 100644
View file @
d80356de
<?xml version="1.0" encoding="UTF-8"?>
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.cesgroup
</groupId>
<artifactId>
沈金奇_Mybatis2
</artifactId>
<version>
1.0-SNAPSHOT
</version>
<dependencies>
<dependency>
<groupId>
mysql
</groupId>
<artifactId>
mysql-connector-java
</artifactId>
<version>
5.1.32
</version>
</dependency>
<!--mybatis-->
<dependency>
<groupId>
org.mybatis
</groupId>
<artifactId>
mybatis
</artifactId>
<version>
3.4.6
</version>
</dependency>
<!--日志-->
<dependency>
<groupId>
org.slf4j
</groupId>
<artifactId>
slf4j-log4j12
</artifactId>
<version>
1.7.25
</version>
</dependency>
<!--junit-->
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
</dependency>
</dependencies>
<build>
<plugins>
<!--用来设置jdk版本的-->
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-compiler-plugin
</artifactId>
<version>
3.7.0
</version>
<configuration>
<source>
1.8
</source>
<target>
1.8
</target>
</configuration>
</plugin>
</plugins>
<resources>
<resource>
<directory>
src/main/resource
</directory>
<includes>
<include>
*.*
</include>
</includes>
</resource>
</resources>
</build>
</project>
\ No newline at end of file
沈金奇_Mybatis2/src/main/java/com/cesgroup/Interceptor/MybatisLogInterceptor.java
0 → 100644
View file @
d80356de
package
com
.
cesgroup
.
Interceptor
;
package
com
.
cesgroup
.
Interceptor
;
import
com.cesgroup.util.ReflectHelper
;
import
org.apache.ibatis.executor.statement.RoutingStatementHandler
;
import
org.apache.ibatis.executor.statement.StatementHandler
;
import
org.apache.ibatis.mapping.BoundSql
;
import
org.apache.ibatis.mapping.ParameterMapping
;
import
org.apache.ibatis.mapping.ParameterMode
;
import
org.apache.ibatis.plugin.Interceptor
;
import
org.apache.ibatis.plugin.Intercepts
;
import
org.apache.ibatis.plugin.Invocation
;
import
org.apache.ibatis.plugin.Signature
;
import
org.apache.ibatis.type.TypeHandlerRegistry
;
import
sun.plugin2.main.server.ResultHandler
;
import
javax.security.auth.login.Configuration
;
import
java.sql.Statement
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Properties
;
import
java.util.logging.Logger
;
@Intercepts
({
@Signature
(
type
=
StatementHandler
.
class
,
method
=
"query"
,
args
=
{
Statement
.
class
,
ResultHandler
.
class
})})
public
class
MybatisLogInterceptor
implements
Interceptor
{
@Override
public
Object
intercept
(
Invocation
invocation
)
throws
Throwable
{
Logger
logger
=
null
;
String
sql
=
null
;
if
(
invocation
.
getTarget
()
instanceof
RoutingStatementHandler
)
{
RoutingStatementHandler
statementHandler
=
(
RoutingStatementHandler
)
invocation
.
getTarget
();
StatementHandler
delegate
=
(
StatementHandler
)
ReflectHelper
.
getValueByFieldName
(
statementHandler
,
"delegate"
);
BoundSql
boundSql
=
delegate
.
getBoundSql
();
Object
parameterObject
=
boundSql
.
getParameterObject
();
List
<
Object
>
params
=
new
ArrayList
<>();
TypeHandlerRegistry
typeHandlerRegistry
=
(
TypeHandlerRegistry
)
ReflectHelper
.
getValueByFieldName
(
delegate
,
"typeHandlerRegistry"
);
Configuration
configuration
=
ReflectHelper
.
getFieldByFieldName
(
delegate
,
"configuration"
);
List
<
ParameterMapping
>
parameterMappings
=
boundSql
.
getParameterMappings
();
if
(
parameterMappings
!=
null
)
{
for
(
int
i
=
0
;
i
<
parameterMappings
.
size
();
i
++)
{
ParameterMapping
parameterMapping
=
parameterMappings
.
get
(
i
);
if
(
parameterMapping
.
getMode
()
!=
ParameterMode
.
OUT
)
{
Object
value
=
null
;
String
propertyName
=
parameterMapping
.
getProperty
();
if
(
boundSql
.
hasAdditionalParameter
(
propertyName
))
{
value
=
boundSql
.
getAdditionalParameter
(
propertyName
);
}
else
if
(
parameterObject
==
null
)
{
value
=
null
;
}
else
if
(
typeHandlerRegistry
.
hasTypeHandler
(
parameterObject
.
getClass
()))
{
value
=
parameterObject
;
}
params
.
add
(
value
);
}
}
}
sql
=
boundSql
.
getSql
();
for
(
Object
param
:
params
)
{
sql
=
sql
.
replaceFirst
(
"[?]]"
,
param
+
""
);
}
}
return
sql
;
}
@Override
public
Object
plugin
(
Object
o
)
{
return
null
;
}
@Override
public
void
setProperties
(
Properties
properties
)
{
}
}
沈金奇_Mybatis2/src/main/java/com/cesgroup/pojo/Student.java
0 → 100644
View file @
d80356de
package
com
.
cesgroup
.
pojo
;
package
com
.
cesgroup
.
pojo
;
import
java.io.Serializable
;
/*
* pojo类
* */
public
class
Student
implements
Serializable
{
private
Integer
id
;
private
String
name
;
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
}
沈金奇_Mybatis2/src/main/java/com/cesgroup/util/ReflectHelper.java
0 → 100644
View file @
d80356de
package
com
.
cesgroup
.
util
;
package
com
.
cesgroup
.
util
;
import
javax.security.auth.login.Configuration
;
import
java.lang.reflect.Field
;
public
class
ReflectHelper
{
public
static
Configuration
getFieldByFieldName
(
Object
obj
,
String
fieldName
)
{
for
(
Class
<?>
superClass
=
obj
.
getClass
();
superClass
!=
Object
.
class
;
superClass
=
superClass
.
getSuperclass
())
{
try
{
return
superClass
.
getDeclaredField
(
fieldName
);
}
catch
(
NoSuchFieldException
e
)
{
}
}
return
null
;
}
public
static
Object
getValueByFieldName
(
Object
obj
,
String
fieldName
)
throws
SecurityException
,
NoSuchFieldException
,
IllegalArgumentException
,
IllegalAccessException
{
Field
field
=
getFieldByFieldName
(
obj
,
fieldName
);
Object
value
=
null
;
if
(
field
!=
null
){
if
(
field
.
isAccessible
())
{
value
=
field
.
get
(
obj
);
}
else
{
field
.
setAccessible
(
true
);
value
=
field
.
get
(
obj
);
field
.
setAccessible
(
false
);
}
}
return
value
;
}
}
沈金奇_Mybatis2/src/main/resources/StudentMapper.xml
0 → 100644
View file @
d80356de
<?xml version="1.0" encoding="UTF-8"?>
<?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">
<mapper
namespace=
"StudentMapper"
>
<select
id=
"selectStudetInfo"
resultType=
"com.cesgroup.pojo.Student"
>
select * from Student where id = #{id}
</select>
</mapper>
沈金奇_Mybatis2/src/main/resources/jdbc.properties
0 → 100644
View file @
d80356de
jdbc.driverClassName
=
com.mysql.jdbc.Driver
jdbc.driverClassName
=
com.mysql.jdbc.Driver
jdbc.url
=
jdbc:mysql://127.0.0.1:3306/Student?useUnicode=true&characterEncoding=utf8&autoReconnect=true&allowMultiQueries=true
jdbc.username
=
root
jdbc.password
=
root
\ No newline at end of file
沈金奇_Mybatis2/src/main/resources/log4j.properties
0 → 100644
View file @
d80356de
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout
=
org.apache.log4j.ConsoleAppender
log4j.appender.stdout.Target
=
System.out
log4j.appender.stdout.layout
=
org.apache.log4j.PatternLayout
log4j.appender.stdout.layout.ConversionPattern
=
%-d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c]-[%p] %m%n
log4j.appender.file
=
org.apache.log4j.FileAppender
log4j.appender.file.File
=
f:/mylog.log
log4j.appender.file.layout
=
org.apache.log4j.PatternLayout
log4j.appender.file.layout.ConversionPattern
=
%-d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c]-[%p] %m%n
log4j.rootLogger
=
debug, stdout
沈金奇_Mybatis2/src/main/resources/mybatis-config.xml
0 → 100644
View file @
d80356de
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<properties
resource=
"jdbc.properties"
/>
<typeAliases>
<!-- 设置别名 -->
<package
name=
"cn.cesgroup.mybatis.pojo"
/>
</typeAliases>
<!--日志插件-->
<plugins>
<plugin
interceptor=
"com.cesgroup.Interceptor.MybatisLogInterceptor"
/>
</plugins>
<!-- 配置数据库连接的环境 -->
<environments
default=
"development"
>
<environment
id=
"development"
>
<transactionManager
type=
"JDBC"
/>
<dataSource
type=
"POOLED"
>
<property
name=
"driver"
value=
"${jdbc.driver}"
/>
<property
name=
"url"
value=
"${jdbc.url}"
/>
<property
name=
"username"
value=
"${jdbc.username}"
/>
<property
name=
"password"
value=
"${jdbc.password}"
/>
</dataSource>
</environment>
</environments>
<mappers>
<package
name=
"com.cesgroup.mybatis.mapper"
/>
</mappers>
</configuration>
沈金奇_Mybatis2/src/main/resources/mybatis.sql
0 → 100644
View file @
d80356de
SET
NAMES
utf8mb4
;
SET
NAMES
utf8mb4
;
SET
FOREIGN_KEY_CHECKS
=
0
;
-- ----------------------------
-- Table structure for mybatis
-- ----------------------------
DROP
TABLE
IF
EXISTS
`mybatis`
;
CREATE
TABLE
`Student`
(
`id`
int
(
32
)
NOT
NULL
,
`name`
varchar
(
255
)
CHARACTER
SET
utf8mb4
COLLATE
utf8mb4_0900_ai_ci
NULL
DEFAULT
NULL
,
PRIMARY
KEY
(
`id`
)
USING
BTREE
)
ENGINE
=
InnoDB
CHARACTER
SET
=
utf8mb4
COLLATE
=
utf8mb4_0900_ai_ci
ROW_FORMAT
=
Dynamic
;
SET
FOREIGN_KEY_CHECKS
=
1
;
沈金奇_Mybatis2/src/test/java/com/cesgroup/Interceptor/MybatisLogInterceptorTest.java
0 → 100644
View file @
d80356de
package
com
.
cesgroup
.
Interceptor
;
package
com
.
cesgroup
.
Interceptor
;
import
com.cesgroup.pojo.Student
;
import
org.apache.ibatis.io.Resources
;
import
org.apache.ibatis.session.SqlSession
;
import
org.apache.ibatis.session.SqlSessionFactory
;
import
org.apache.ibatis.session.SqlSessionFactoryBuilder
;
import
org.junit.Before
;
import
org.junit.Test
;
import
java.io.InputStream
;
public
class
MybatisLogInterceptorTest
{
private
SqlSession
sqlSession
=
null
;
private
SqlSessionFactory
sqlSessionFactory
;
@Before
public
void
configMybatis
()
{
String
resource
=
"mybatis-config.xml"
;
InputStream
inputStream
;
try
{
inputStream
=
Resources
.
getResourceAsStream
(
resource
);
sqlSessionFactory
=
new
SqlSessionFactoryBuilder
().
build
(
inputStream
);
sqlSession
=
sqlSessionFactory
.
openSession
(
false
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
finally
{
if
(
sqlSession
!=
null
)
{
sqlSession
.
close
();
}
}
}
@Test
public
void
testMybatisSelectStudent
()
{
Student
stu
=
sqlSession
.
selectOne
(
"StudentMapper.selectStudetInfo"
,
16
);
System
.
out
.
println
(
stu
);
sqlSession
.
close
();
}
}
\ No newline at end of file
沈金奇_Mybatis2/沈金奇_Mybatis2.iml
0 → 100644
View file @
d80356de
<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<module
org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule=
"true"
type=
"JAVA_MODULE"
version=
"4"
>
<component
name=
"NewModuleRootManager"
LANGUAGE_LEVEL=
"JDK_1_8"
>
<output
url=
"file://$MODULE_DIR$/target/classes"
/>
<output-test
url=
"file://$MODULE_DIR$/target/test-classes"
/>
<content
url=
"file://$MODULE_DIR$"
>
<sourceFolder
url=
"file://$MODULE_DIR$/src/main/java"
isTestSource=
"false"
/>
<sourceFolder
url=
"file://$MODULE_DIR$/src/test/java"
isTestSource=
"true"
/>
<excludeFolder
url=
"file://$MODULE_DIR$/target"
/>
</content>
<orderEntry
type=
"inheritedJdk"
/>
<orderEntry
type=
"sourceFolder"
forTests=
"false"
/>
<orderEntry
type=
"library"
name=
"Maven: mysql:mysql-connector-java:5.1.32"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.mybatis:mybatis:3.4.6"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:slf4j-log4j12:1.7.25"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.slf4j:slf4j-api:1.7.25"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: log4j:log4j:1.2.17"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: junit:junit:4.12"
level=
"project"
/>
<orderEntry
type=
"library"
name=
"Maven: org.hamcrest:hamcrest-core:1.3"
level=
"project"
/>
</component>
</module>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment