![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
springboot
tuantuanyuyu
这个作者很懒,什么都没留下…
展开
-
springboot项目获取resouce下面的xml文件
方法一:在linux跟windows下,将springboot打包成war,可以获取,但是springboot打包成jar包就找不到该文件了 String path = Thread.currentThread().getContextClassLoader().getResource("app.xml").getPath(); System.out.println("------path---" + path); File file = new File(path); if (file.exi原创 2020-09-22 16:42:01 · 1424 阅读 · 0 评论 -
Spring Boot 项目中的三种多数据源方案,一个比一个强!
“摘要: 原创出处 http://www.iocoder.cn/Spring-Boot/dynamic-datasource/ 「芋道源码」欢迎转载,保留摘要,谢谢! 1. 概述 2. 实现方式 2.1 方案一 2.2 方案二 2.3 方案三 3. baomidou 多数据源 4. baomidou 读写分离 5. MyBatis 多数据源 6. Spring Data JPA 多数据源转载 2020-07-24 13:59:09 · 4364 阅读 · 5 评论 -
7、springboot多模块多数据源全局事务的设置
1、绑定第一个数据库/** * 创建多数据源的过程就是:首先创建 DataSource, * 注入到 SqlSessionFactory 中,再创建事务, * 将 SqlSessionFactory 注入到创建的 SqlSessionTemplate 中, * 最后将 SqlSessionTemplate 注入到对应的 Mapper 包路径下。 * 其中需要指定分库的 Mapper...原创 2019-11-15 14:14:09 · 1156 阅读 · 0 评论 -
1、springboot使用gson()启动的时候报错
最近项目开始使用springboot了,记录下从开始搭建到使用过程中一些技术点,以及出现的问题An attempt was made to call the method com.google.gson.GsonBuilder.setLenient()Lcom/google/gson/GsonBuilder; but it does not exist. Its class, com.goog...原创 2019-08-28 10:50:46 · 989 阅读 · 0 评论 -
2、给springboot创建拦截器跟过滤器
1、过滤器:直接添加@Component注解即可,然后处理doFilter业务逻辑@Componentpublic class CipherArgsCheckFilter implements Filter {@Overridepublic void doFilter(ServletRequest request, ServletResponse response, FilterC...原创 2019-08-28 10:56:21 · 146 阅读 · 0 评论 -
3、springboot部署到tomcat下
springboot一般直接运行文件,部署时打包成jar包,它还可以直接部署到tomcat,这样对于某些配置文件可以直接替换,不需要再重新打包1、jar包中去掉springboot自带的tomcat<dependency> <groupId>org.springframework.boot</groupId> <artifactI...原创 2019-08-28 11:09:01 · 274 阅读 · 0 评论 -
4、springboot+mybatis通用mapper配置
对于dao层里面的文件,如果想要加载的话,每一个文件都需要注解@Mapper,这样文件多了,挺麻烦,可以使用通用mapper,这些文件都继承该文件即可1、创建统一的mapperapplication.yml配置文件下mapper: mappers: com.test.comm.mapper.SqlMapper该文件要跟其他dao层文件不妨到一个包中2、添加SqlMappe...原创 2019-08-28 11:15:50 · 271 阅读 · 0 评论 -
6、springboot计划任务
1、添加注解 @EnableScheduling@EnableTransactionManagement@SpringBootApplication@MapperScan("me.uniauto.dao.persistence")@EnableSchedulingpublic class AdminApplication extends SpringBootServletIni...原创 2019-08-28 11:54:18 · 126 阅读 · 0 评论 -
5、springboot开启异步
1、在启动程序中添加注解@EnableAsync,开启事务@EnableAsync@SpringBootApplicationpublic class AdminApplication extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(...原创 2019-08-28 14:44:59 · 102 阅读 · 0 评论