Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
jinli gu
RuoYi Vue
Commits
9d450704
Commit
9d450704
authored
Feb 24, 2020
by
RuoYi
Browse files
设置mybatis全局的配置文件
parent
cb0a4b78
Changes
1
Hide whitespace changes
Inline
Side-by-side
ruoyi/src/main/java/com/ruoyi/framework/config/MyBatisConfig.java
View file @
9d450704
...
...
@@ -13,6 +13,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.core.env.Environment
;
import
org.springframework.core.io.DefaultResourceLoader
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.support.PathMatchingResourcePatternResolver
;
import
org.springframework.core.io.support.ResourcePatternResolver
;
...
...
@@ -93,6 +94,7 @@ public class MyBatisConfig
{
String
typeAliasesPackage
=
env
.
getProperty
(
"mybatis.typeAliasesPackage"
);
String
mapperLocations
=
env
.
getProperty
(
"mybatis.mapperLocations"
);
String
configLocation
=
env
.
getProperty
(
"mybatis.configLocation"
);
typeAliasesPackage
=
setTypeAliasesPackage
(
typeAliasesPackage
);
VFS
.
addImplClass
(
SpringBootVFS
.
class
);
...
...
@@ -100,6 +102,7 @@ public class MyBatisConfig
sessionFactory
.
setDataSource
(
dataSource
);
sessionFactory
.
setTypeAliasesPackage
(
typeAliasesPackage
);
sessionFactory
.
setMapperLocations
(
new
PathMatchingResourcePatternResolver
().
getResources
(
mapperLocations
));
sessionFactory
.
setConfigLocation
(
new
DefaultResourceLoader
().
getResource
(
configLocation
));
return
sessionFactory
.
getObject
();
}
}
\ No newline at end of file
Write
Preview
Supports
Markdown
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