package com.cwh;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.log4j.Logger;
import org.apache.tomcat.jdbc.pool.DataSource;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.PlatformTransactionManager;
@EnableAutoConfiguration
@SpringBootApplication
@ComponentScan
@MapperScan("com.cwh.mapper")
public class Application {
private static Logger logger = Logger.getLogger(Application.class);
@Bean
@ConfigurationProperties(prefix="spring.datasource")
public DataSource dataSource() {
return new org.apache.tomcat.jdbc.pool.DataSource();
}
@Bean
public SqlSessionFactory sqlSessionFactoryBean() throws Exception {
SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
sqlSessionFactoryBean.setDataSource(dataSource());
PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath:/mybatis/*.xml"));
return sqlSessionFactoryBean.getObject();
}
@Bean
public PlatformTransactionManager transactionManager() {
return new DataSourceTransactionManager(dataSource());
}
/**
* Start
*/
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
logger.info("SpringBoot Start Success");
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
springboot + springMVC整合源码
共35个文件
xml:6个
class:5个
java:5个
5星 · 超过95%的资源 需积分: 50 48 下载量 96 浏览量
2017-11-20
12:15:34
上传
评论
收藏 16KB RAR 举报
温馨提示
springboot整合springMVC,实现和mysql数据库交互,都是源码
资源推荐
资源详情
资源评论
收起资源包目录
springboot.rar (35个子文件)
springboot
pom.xml 3KB
target
test-classes
m2e-jee
web-resources
META-INF
maven
com.cwh
springboot
pom.xml 3KB
pom.properties 238B
MANIFEST.MF 270B
classes
application.properties 286B
templates
user.html 454B
com
cwh
model
User.class 959B
mapper
UserMapper.class 223B
controller
UserController.class 2KB
service
UserService.class 852B
Application.class 3KB
mybatis
UserMapper.xml 332B
.settings
com.genuitec.eclipse.j2eedt.core.prefs 56B
org.eclipse.m2e.core.prefs 90B
org.eclipse.wst.jsdt.ui.superType.name 6B
com.genuitec.eclipse.core.prefs 74B
org.eclipse.wst.common.project.facet.core.xml 252B
org.eclipse.wst.common.component 583B
org.eclipse.wst.jsdt.ui.superType.container 49B
.jsdtscope 508B
org.eclipse.jdt.core.prefs 664B
src
main
webapp
META-INF
MANIFEST.MF 39B
WEB-INF
web.xml 215B
classes
lib
index.jsp 52B
resources
application.properties 286B
templates
user.html 454B
mybatis
UserMapper.xml 332B
java
com
cwh
model
User.java 566B
Application.java 2KB
mapper
UserMapper.java 156B
controller
UserController.java 1KB
service
UserService.java 472B
.project 2KB
.mymetadata 311B
.classpath 605B
共 35 条
- 1
资源评论
- xly5202019-03-14很好很不错详细
babaozhou_1234
- 粉丝: 0
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 实验项目一:线性表(模板 ).docx
- 基于LM317A设计交流220V输入可调5V-12V直流输出稳压电源电路multisim10仿真源文件.zip
- Screenshot_2024-04-25-17-04-18-55_2332cb9b27b851b548ba47a91682926c.jpg
- -基于AVR单片机的LNG加液机控制器设计.pdf
- ThePowerOfNow-EckhartTolle.mobi
- BLOCK_TYPE_HEARTBEAT_D70A3465D4EE4E9_046141_dump_1st.dmp
- 项目方法测试调用接口工具
- studyupdate
- 基于西瓜数据集的决策树实现.zip
- 60套HTML网站源码-响应式-涵盖(简历&作品展示&商业&科技&培训&商城&课设等)-适配移动设备-解压即用.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功