Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
Mybatis Demo
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
study-java
Mybatis Demo
Commits
41760925
Commit
41760925
authored
Nov 20, 2020
by
宋欢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
data-source
parent
60976805
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
8 deletions
+14
-8
MyBatis课件.txt
MyBatis课件.txt
+6
-0
Application.java
...in/java/cn/qmai/study/java/demo/web/main/Application.java
+1
-1
data-source.xml
demo-web/src/main/resources/data-source.xml
+7
-7
No files found.
MyBatis课件.txt
View file @
41760925
MySQL的操作,离不开Laravel-DB和Model,简单一句话,DB::table('user')->where('id', 1)->first();
MySQL的操作,离不开Laravel-DB和Model,简单一句话,DB::table('user')->where('id', 1)->first();
Java也有类似Laravel-DB的ORM框架,之前流行Hibernate,现在我们用MyBatis
Java也有类似Laravel-DB的ORM框架,之前流行Hibernate,现在我们用MyBatis
配置
demo-web/src/main/java/cn/qmai/study/java/demo/web/main/Application.java
View file @
41760925
...
@@ -23,7 +23,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
...
@@ -23,7 +23,7 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
@EnableTransactionManagement
@EnableTransactionManagement
@EnableScheduling
@EnableScheduling
@ComponentScan
(
basePackages
=
{
"cn.qmai.study.java.demo"
})
@ComponentScan
(
basePackages
=
{
"cn.qmai.study.java.demo"
})
@ImportResource
(
locations
=
{
"classpath:data-s
haring
.xml"
})
@ImportResource
(
locations
=
{
"classpath:data-s
ource
.xml"
})
@EnableSwagger2
@EnableSwagger2
public
class
Application
{
public
class
Application
{
...
...
demo-web/src/main/resources/data-s
haring
.xml
→
demo-web/src/main/resources/data-s
ource
.xml
View file @
41760925
...
@@ -41,7 +41,7 @@
...
@@ -41,7 +41,7 @@
</bean>
</bean>
<!-- 配置,连接、用户名、密码 -->
<!-- 配置,连接、用户名、密码 -->
<bean
id=
"dataS
ynDs
"
parent=
"abstractDataSource"
primary=
"false"
>
<bean
id=
"dataS
ource
"
parent=
"abstractDataSource"
primary=
"false"
>
<property
name=
"url"
<property
name=
"url"
value=
"jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true"
/>
value=
"jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true"
/>
<property
name=
"username"
value=
"root"
/>
<property
name=
"username"
value=
"root"
/>
...
@@ -50,8 +50,8 @@
...
@@ -50,8 +50,8 @@
</bean>
</bean>
<!-- Mybatis 配置 -->
<!-- Mybatis 配置 -->
<bean
id=
"dataS
yn
Mybatis"
class=
"org.mybatis.spring.SqlSessionFactoryBean"
>
<bean
id=
"dataS
ource
Mybatis"
class=
"org.mybatis.spring.SqlSessionFactoryBean"
>
<property
name=
"dataSource"
ref=
"dataS
ynDs
"
/>
<property
name=
"dataSource"
ref=
"dataS
ource
"
/>
<property
name=
"typeAliasesPackage"
value=
"cn.qmai.study.java.demo.biz.model"
/>
<property
name=
"typeAliasesPackage"
value=
"cn.qmai.study.java.demo.biz.model"
/>
<property
name=
"mapperLocations"
value=
"classpath:/mappings/*.xml"
/>
<property
name=
"mapperLocations"
value=
"classpath:/mappings/*.xml"
/>
<property
name=
"configLocation"
value=
"classpath:/mybatis.xml"
/>
<property
name=
"configLocation"
value=
"classpath:/mybatis.xml"
/>
...
@@ -59,13 +59,13 @@
...
@@ -59,13 +59,13 @@
</bean>
</bean>
<!-- Mybatis 接口扫描 -->
<!-- Mybatis 接口扫描 -->
<bean
id=
"dataS
yn
Scanner"
class=
"org.mybatis.spring.mapper.MapperScannerConfigurer"
>
<bean
id=
"dataS
ource
Scanner"
class=
"org.mybatis.spring.mapper.MapperScannerConfigurer"
>
<property
name=
"sqlSessionFactoryBeanName"
value=
"dataS
yn
Mybatis"
/>
<property
name=
"sqlSessionFactoryBeanName"
value=
"dataS
ource
Mybatis"
/>
<property
name=
"basePackage"
value=
"cn.qmai.study.java.demo.biz.dao"
/>
<property
name=
"basePackage"
value=
"cn.qmai.study.java.demo.biz.dao"
/>
</bean>
</bean>
<!-- 定义事务 -->
<!-- 定义事务 -->
<bean
id=
"dataS
yn
Transaction"
class=
"org.springframework.jdbc.datasource.DataSourceTransactionManager"
>
<bean
id=
"dataS
ource
Transaction"
class=
"org.springframework.jdbc.datasource.DataSourceTransactionManager"
>
<property
name=
"dataSource"
ref=
"dataS
ynDs
"
/>
<property
name=
"dataSource"
ref=
"dataS
ource
"
/>
</bean>
</bean>
</beans>
</beans>
\ 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