package Wss.com.config;
import com.alibaba.druid.pool.DruidDataSource;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
import javax.sql.DataSource;
import java.io.IOException;
@Configuration
@ComponentScan("Wss.com")
@PropertySource("classpath:application.properties")
public class AppConfig {
@Value("com.mysql.jdbc.Driver")
private String driver;
@Value("jdbc:mysql://localhost:3306/persons?characterEncoding=utf-8&useSSL=false")
private String url;
@Value("root")
private String user;
@Value("root")
private String password;
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
@Bean
public DataSource dataSource() {
DruidDataSource druidDataSource = new DruidDataSource();
druidDataSource.setDriverClassName(driver);
druidDataSource.setUrl(url);
druidDataSource.setUsername(user);
druidDataSource.setPassword(password);
return druidDataSource;
}
@Bean
public static SqlSessionFactoryBean sqlSessionFactoryBean(@Autowired DataSource dataSource) {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource);
sqlSessionFactoryBean.setTypeAliasesPackage("Wss.com.entity");
PathMatchingResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
try {
sqlSessionFactoryBean.setMapperLocations(resourcePatternResolver.getResources("classpath:mapper/**/*.xml"));
} catch (IOException e) {
e.printStackTrace();
}
return sqlSessionFactoryBean;
}
@Bean
public static MapperScannerConfigurer mapperScannerConfigurer() {
MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactoryBean");
mapperScannerConfigurer.setBasePackage("Wss.com.mapper");
return mapperScannerConfigurer;
}
@Bean
public PlatformTransactionManager platformTransactionManager(@Autowired DataSource dataSource) {
PlatformTransactionManager platformTransactionManager = new DataSourceTransactionManager(dataSource);
return platformTransactionManager;
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
初学Spring+SpringMVC+MyBatis框架(适合初学者看相对完整些)
共127个文件
jar:76个
class:14个
xml:13个
3星 · 超过75%的资源 需积分: 50 93 下载量 77 浏览量
2018-07-09
09:26:04
上传
评论 1
收藏 33.95MB ZIP 举报
温馨提示
这次比上次的做了写改动,仍然是基于IDEA做的。欢迎初学者来看。有什么问题可以直接提问,大家一起来学习。
资源推荐
资源详情
资源评论
收起资源包目录
初学Spring+SpringMVC+MyBatis框架(适合初学者看相对完整些) (127个子文件)
AppConfig.class 3KB
AppConfig.class 3KB
DispatcherConfig.class 2KB
DispatcherConfig.class 2KB
PersonController.class 2KB
PersonController.class 2KB
PersonEntity.class 2KB
PersonEntity.class 2KB
WebInitializer.class 859B
WebInitializer.class 859B
PersonMapper.class 537B
PersonMapper.class 537B
Main.class 253B
Main.class 253B
person.iml 1KB
druid-1.1.6.jar 2.56MB
druid-1.1.6.jar 2.56MB
aspectjweaver-1.8.10.jar 1.84MB
aspectjweaver-1.8.10.jar 1.84MB
mybatis-3.4.4.jar 1.53MB
mybatis-3.4.4.jar 1.53MB
jackson-databind-2.9.1.jar 1.27MB
jackson-databind-2.9.1.jar 1.27MB
spring-context-4.3.10.RELEASE.jar 1.09MB
spring-context-4.3.10.RELEASE.jar 1.09MB
spring-core-4.3.10.RELEASE.jar 1.07MB
spring-core-4.3.10.RELEASE.jar 1.07MB
mysql-connector-java-5.1.40.jar 968KB
mysql-connector-java-5.1.40.jar 968KB
spring-webmvc-4.3.10.RELEASE.jar 894KB
spring-webmvc-4.3.10.RELEASE.jar 894KB
spring-web-4.3.10.RELEASE.jar 803KB
spring-web-4.3.10.RELEASE.jar 803KB
spring-beans-4.3.10.RELEASE.jar 745KB
spring-beans-4.3.10.RELEASE.jar 745KB
hibernate-validator-5.3.6.Final.jar 710KB
hibernate-validator-5.3.6.Final.jar 710KB
spring-test-4.3.10.RELEASE.jar 586KB
spring-test-4.3.10.RELEASE.jar 586KB
spring-orm-4.3.10.RELEASE.jar 466KB
spring-orm-4.3.10.RELEASE.jar 466KB
spring-websocket-4.3.10.RELEASE.jar 446KB
spring-websocket-4.3.10.RELEASE.jar 446KB
spring-jdbc-4.3.10.RELEASE.jar 418KB
spring-jdbc-4.3.10.RELEASE.jar 418KB
jstl-1.2.jar 405KB
jstl-1.2.jar 405KB
spring-messaging-4.3.10.RELEASE.jar 376KB
spring-messaging-4.3.10.RELEASE.jar 376KB
spring-aop-4.3.10.RELEASE.jar 372KB
spring-aop-4.3.10.RELEASE.jar 372KB
jackson-core-2.9.1.jar 313KB
jackson-core-2.9.1.jar 313KB
spring-jms-4.3.10.RELEASE.jar 283KB
spring-jms-4.3.10.RELEASE.jar 283KB
spring-tx-4.3.10.RELEASE.jar 261KB
spring-tx-4.3.10.RELEASE.jar 261KB
spring-expression-4.3.10.RELEASE.jar 257KB
spring-expression-4.3.10.RELEASE.jar 257KB
spring-context-support-4.3.10.RELEASE.jar 183KB
spring-context-support-4.3.10.RELEASE.jar 183KB
spring-webmvc-portlet-4.3.10.RELEASE.jar 173KB
spring-webmvc-portlet-4.3.10.RELEASE.jar 173KB
commons-io-2.2.jar 170KB
commons-io-2.2.jar 170KB
tomcat-jdbc.jar 141KB
tomcat-jdbc.jar 141KB
spring-oxm-4.3.10.RELEASE.jar 83KB
spring-oxm-4.3.10.RELEASE.jar 83KB
commons-fileupload-1.3.1.jar 67KB
commons-fileupload-1.3.1.jar 67KB
jackson-annotations-2.9.1.jar 65KB
jackson-annotations-2.9.1.jar 65KB
classmate-1.3.4.jar 64KB
classmate-1.3.4.jar 64KB
validation-api-1.1.0.Final.jar 62KB
validation-api-1.1.0.Final.jar 62KB
commons-logging-1.2.jar 60KB
commons-logging-1.2.jar 60KB
spring-aspects-4.3.10.RELEASE.jar 57KB
spring-aspects-4.3.10.RELEASE.jar 57KB
jboss-logging-3.1.4.GA.jar 56KB
jboss-logging-3.1.4.GA.jar 56KB
mybatis-spring-1.3.1.jar 52KB
mybatis-spring-1.3.1.jar 52KB
spring-instrument-tomcat-4.3.10.RELEASE.jar 10KB
spring-instrument-tomcat-4.3.10.RELEASE.jar 10KB
spring-instrument-4.3.10.RELEASE.jar 7KB
spring-instrument-4.3.10.RELEASE.jar 7KB
aopalliance-1.0.jar 4KB
aopalliance-1.0.jar 4KB
AppConfig.java 3KB
PersonController.java 1KB
DispatcherConfig.java 1KB
PersonEntity.java 1KB
PersonMapper.java 611B
WebInitializer.java 582B
Main.java 44B
jquery-3.2.1.min.js 85KB
jquery-3.2.1.min.js 85KB
共 127 条
- 1
- 2
资源评论
- 啤酒2020-08-04不是我想要的,浪费积分求返还
- 11256095392019-08-26还可以,入门学习看看阿狐狸2019-08-29谢谢
阿狐狸
- 粉丝: 5
- 资源: 5
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于Matlab人脸肤色定理的教师人数统计+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab霍夫曼变换的表盘读数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab火灾烟雾检测源码带GUI界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的恶劣天气交通标志识别系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的霍夫曼变换的表盘示数识别+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab的车道线识别系统 +源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的教室人数统计系统带Gui界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB的教室人数统计系统带Gui界面+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于MATLAB 的霍夫曼变换答题卡识别源码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
- 基于Matlab+bp神经网络的神经网络汉字识别系统+源代码+全部数据+文档说明+详细注释+使用说明+截图(高分课程设计)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功