![](https://img-blog.csdnimg.cn/20201014180756757.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Spring Boot
一只小棉花
这个作者很懒,什么都没留下…
展开
-
SpringBoot第一讲 概览
在使用了一段时间的springboot之后,今天决定开始弄一套完整的springboot的教程,说实话在学习springboot之前,个人已经开始厌倦了代码的编写和视频教程的录制,因为每次录制视频教程那怕一个简单的hello world都不得不面对大量的配置文件,一个helloworld测试程序,业务逻辑只是几秒钟的事情,但是却要花上十多分钟来进行配置。现在有了springboot之后...转载 2017-03-21 16:10:52 · 303 阅读 · 1 评论 -
spring Aware接口-ApplicationContextAware
看源码,这个接口位于org.springframework.beans.factorypackage org.springframework.beans.factory;public interface Aware {}看下其子类先看第一个,即ApplicationContextAware接口public interface ApplicationContextAw...原创 2019-01-14 11:06:30 · 147 阅读 · 0 评论 -
springboot 自动配置
从启动类开始,import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplicationpublic class Application { public static void...原创 2019-01-09 00:37:15 · 136 阅读 · 0 评论 -
springboot 热更新
在使用eclipse对springboot项目进行调试时,比如更改了html页面的内容或某个controller类的代码,还需要手动关闭服务器-再开启,太麻烦,怎么办?在pom文件中加上如下依赖即可解决上面的问题<dependency> <groupId>org.springframework.boot</groupId> <ar...原创 2019-01-14 23:28:14 · 2628 阅读 · 0 评论 -
springboot 跳转至页面遇到的问题
问题汇总(先声明,我的springboot 版本是1.5.7.RELEASE):1、想跳转到某个页面,但是页面上却显示字符串,比如检查下controller类@Controllerpublic class HomeController { @RequestMapping(value="/index",method = RequestMethod.GET) @Respon...原创 2019-01-15 00:10:25 · 1045 阅读 · 0 评论 -
springboot 启动过程中,web环境的判断
springboot在初始化过程中,会校验当前项目是否满足web环境,是如何做到的?很简单在SpringApplication类initialize(Object[] sources)初始化方法里面,第6行是向webEnvironment赋值,调用的是13行的deduceWebEnvironment()方法,@SuppressWarnings({ "unchecked", "rawtyp...原创 2019-01-09 16:13:38 · 2443 阅读 · 0 评论 -
springboot 上传文件
1、先写好controller类,有两个方法,getUploadPage()方法是接收请求,跳转到upload.html页面,upload(@RequestParam("file") MultipartFile file)方法,处理上传的文件@Controllerpublic class HomeController { @Value("${uploadPath}") private...转载 2019-01-15 18:22:20 · 268 阅读 · 0 评论 -
springboot 单元测试报错
在单元测试时,报错如下:The import org.springframework.test.context.junit4.SpringRunner cannot be resolved@RunWith(SpringRunner.class)@SpringBootTestpublic class UserDaoTest {}大概说的是SpringRunner这个类找不到我...原创 2019-01-15 22:23:48 · 1127 阅读 · 0 评论 -
springboot 整合MongoDB
1、先安装MongoDB,网上资料很多,就不多说了。或者看我的这篇安装教程(Win7 64位安装MongoDB 4.0.5)https://blog.csdn.net/baofengyu90/article/details/864983142、pom添加依赖<dependency> <groupId>org.springframework.boot<...原创 2019-01-15 22:52:13 · 206 阅读 · 0 评论 -
maven子项目引用父项目jar包
如果父项目pom中使用的是:<dependencies> ....</dependencies>方式,则子项目pom会自动使用pom中的jar包。如果父项目pom使用<dependencyManagement> <dependencies> .... </dependencies&g...转载 2019-01-16 20:43:10 · 5315 阅读 · 0 评论 -
springboot mybatis mysql整合遇到乱码
问题描述:数据插入mysql数据库后,出现乱码检查eclipse的文件编码等都是utf-8格式,没发现问题检查mysql数据库参数发现,下面标红的有问题,需要重新设置character_set_server参数我的mysql安装在windows7上,且免安装,没有找到(网上所说的)my.ini文件,只有my-default.ini文件按照网上的其他教程,复制my-defau...原创 2019-01-16 22:55:12 · 342 阅读 · 0 评论 -
springboot mybatis整合
项目介绍:这个项目是使用maven多模块构建的父pom文件<?xml version="1.0" encoding="UTF-8"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaL...原创 2019-01-16 22:56:24 · 149 阅读 · 0 评论 -
springboot 启动流程(一)
现在做什么?(思路:按着控制台打印的日志,找一下springboot启动过程中都做了哪些工作)回:下午心血来潮,想看看springboot启动流程是什么?就在resources目录下新建了logback.xml,日志级别设置成DEBUG模式,启动项目,控制台打印出日志如下:为了找到标红的那行日志,一步一步找,不太好找,先声明一下我的springboot版本:1.5.7.RELEASE,...原创 2019-01-02 17:28:59 · 304 阅读 · 0 评论 -
springboot 启动流程(二)
8、接着上一节,继续在步骤7里面提到,父类AbstractEnvironment里面的构造函数 public AbstractEnvironment() { customizePropertySources(this.propertySources); if (logger.isDebugEnabled()) { logger.debug("Initialized " + ...原创 2019-01-06 22:59:49 · 178 阅读 · 0 评论 -
SpringBoot第二讲 利用Spring Data JPA实现数据库的访问(一)
在基本了解了springboot的运行流程之后,我们需要逐个来突破springboot的几个关键性问题,我们首先解决的是springboot访问数据库的问题。Java访问数据库经历了几个阶段,第一个阶段是直接通过JDBC访问,这种方式工作量极大,而且会做大量的重复劳动,之后出现了一些现成的ORM框架,如hibernate、Mybatis等,这些框架封装了大量的数据库的访问操作,但是我们...转载 2017-03-21 16:22:46 · 656 阅读 · 1 评论 -
SpringBoot第二讲 利用Spring Data JPA实现数据库的访问(二)_分页和JpaSpecificationExecutor接口介绍
我们继续研究spring jpa data,首先看看分页和排序的实现,在原来的代码中,我们如果希望实现分页,首先得创建一个Pager的对象,在这个对象中记录total(总数),totalPager(总页数),pageSize(每页多少条记录),pageIndex(当前第几页),offset(查询时的offset),在spring Data JPA中实现分页需要用到三个接口 - PagingAnd...转载 2017-03-21 16:29:53 · 505 阅读 · 0 评论 -
springboot + mybatis 报错: org.apache.ibatis.binding.BindingException: Invalid bound statement
最近从网上下载了一个开源项目,在本地跑了一下,报错:Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.xxx.xxx.dao.***Dao.****Update仔细检查了一下*Mapper.xml 文件中的sql是否有语法错误、dao类里面...原创 2018-09-26 21:00:50 · 737 阅读 · 0 评论 -
spring boot 启动报错:找不到或无法加载主类 com.xxx.xxx.xxx.Application
简要描述:我是maven clean以后,报这个错,也就是说经过clean操作把class文件都干掉了,能不报这个错就奇怪了。再次build(编译)就行了。 问题描述:开发工具:eclipse,先后执行:项目-》右键-》Run As -》Maven clean 和 菜单栏Project-》Clean...-》选中当前项目执行,上述Clean操作后,再开启spring boot就报错:找不...原创 2018-09-26 21:25:46 · 61035 阅读 · 6 评论 -
Could not find result map com.xxx.xxx.xxxDao.map
springboot + mybatis 启动报错:Could not find result map com.xxx.xxx.xxxDao.map 又仔细检查了mapper配置文件,发现<select id="selectBaseScheduler" parameterType="hashMap" resultMap="map">resultMap没有配置正确,因...原创 2018-10-11 16:38:35 · 4954 阅读 · 0 评论 -
springboot报如下信息:Consider defining a bean of type 'com.***.Handler' in your configuration
场景描述:springboot 没启动成功,报如下信息:Description:Field syslogHandler in com.***.ProcessSyslog required a bean of type'com.***.Handler' that could not be found.Consider defining a bean of type 'com....原创 2018-12-06 10:21:46 · 3184 阅读 · 0 评论 -
Error getting generated key or setting result to parameter object. Cause:不允许的操作
问题描述:在springboot项目中,用到了一个mapper配置文件,里面有一个<insert> merge into 表a 的sql语句</insert>在测试的时候报错,错误描述如下:org.springframework.jdbc.UncategorizedSQLException: Error getting generated key or se...原创 2018-12-10 15:35:31 · 12232 阅读 · 0 评论 -
springboot mybatis merge into 用法
例子:<update id="insert" parameterType="***.***.***.实体"> merge into 表名 a using (select 1 from dual) on (a.字段1 = #{参数} and a.字段2 = #{参数2}) when not matched then in...原创 2018-12-29 16:38:59 · 2665 阅读 · 0 评论 -
springboot mybatis 使用set集合
首先,在dao接口层方法上加上Param注解public int test(@Param("set") Set<String> recordIds);不加注解,会报错!接着,在mybatis mapper文件中添加<update id="test" parameterType="java.util.Set" > update 表名 sr ...原创 2018-12-29 16:52:11 · 3610 阅读 · 0 评论 -
springboot rabbitmq
前提条件:1、本地已安装rabbitmq服务端(网上资料很多,此篇未介绍)2、已搭建好springboot项目环境步骤:1、添加依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-amqp&l...原创 2018-12-31 17:57:36 · 211 阅读 · 0 评论 -
Springboot 启动报错:Cannot determine embedded database driver class for database type NONE.
问题描述:搭建了一个简单的springboot小项目,包括:一个启动类和一个controller,没有用到数据库连接启动的时候报错:nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException: Cannot deter...原创 2019-01-01 17:12:06 · 353 阅读 · 0 评论 -
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.***.addUserInfo
问题描述:在springboot 整合mybatis时报这个错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.***.collect.dao.UserInfoDao.addUserInfo at org.apache.ibatis.binding.MapperMe...原创 2019-01-16 23:01:03 · 230 阅读 · 0 评论