
SpringBoot
微wx笑
无知人生,记录点滴 不积跬步,无以至千里;不积小流,无以成江海……
-
原创 SpringBoot druid配置datasource启动初始化数据库连接
1、问题场景:1.1、服务在启动之后的第一笔或者几笔请求,处理时间较长,对于调用方来说超时,引发技术保底。1.2、数据库连接信息配置错误,项目启动过程中却不产生任何异常,等到实际功能用到数据库了才抛出异常。2、问题分析:2.1、调用发系统通过http请求调用服务,设置超时时间为1s,超时时间过短,调整为3s;2.2、应用启动之后的初始几笔请求处理时间过长,超过1s,跟踪日志发现在in...2019-03-12 15:20:1916695
2
-
原创 Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could
刚创建的 Spring Boot 项目,启动后输出:Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.2018-07-03 13:52:44.978 ERROR 6161 --- [ restartedMain] o.s...2018-07-03 14:55:0528273
3
-
原创 Property 'server.jsp-servlet.init-parameters' is Deprecated: Use 'server.servlet.jsp.init-parameters
Property 'server.jsp-servlet.init-parameters' is Deprecated: Use 'server.servlet.jsp.init-parameters' instead.鼠标移动到错误上会弹出提示:意思是 server.jsp-servlet.init-parameters.development已废弃,需要修改为: server.servlet....2018-07-03 14:20:223593
2
-
原创 Could not resolve view with name 'xxx' in servlet with name dispatcherServlet
SpringBoot 项目,启动后访问网页,控制台输出:javax.servlet.ServletException: Could not resolve view with name 'loginback' in servlet with name 'dispatcherServlet'这是因为模板文件相关配置不正确,导致找不到模板文件所致。关于配置,请参考:SpringBoot 项目 @Ena...2018-05-16 15:07:1041415
8
-
原创 SpringBoot中AOP的应用记录
AOP目的: 面向切面编程(aspect-oriented programming,AOP)主要实现的目的是针对业务处理过程中的切面进行提取,诸如日志、事务管理和安全这样的系统服务,从而使得业务逻辑各部分之间的耦合度降低,提高程序的可重用性,同时提高了开发的效率。Spring AOP术语:1.连接点(Joinpoint) 程序执行的某个特定位置:如类某个方法调用前、调用后、方法抛出异常...2018-05-15 17:29:397495
1
-
转载 SpringBoot 拦截器(Interceptor)的使用
拦截器intercprot 和 过滤器 Filter 其实作用类似在最开始接触java 使用struts2的时候,里面都是filter后来springmvc时就用interceptor没太在意过区别,反正就是起检查作用的,仔细阅读 过滤器(filter)和拦截器(interceptor)的区别 后明白了不少最重要的要记住他们的执行顺序: 先filter 后 interceptor过滤前-拦截前-...2018-05-11 13:36:4751545
2
-
原创 spring boot 配置Filter过滤器方法总结
相关概念参考:AOP(面向切面编程)、Filter(过虑器)、Interceptor(拦截器)工作原理及代码参考:Java三大器之过滤器(Filter)的工作原理和代码演示spring boot 配置Filter过滤器1、通过注解来配置@Component@WebFilter(urlPatterns = "/webapi/*", filterName = "authFilter")public...2018-05-10 12:21:3167429
14
-
原创 Failed to bind properties under 'spring.datasource.type' to java.lang.Class
刚创建的 Spring Boot 2.0 项目,启动后输出:Failed to bind properties under 'spring.datasource.type' to java.lang.Class<javax.sql.DataSource>: Property: spring.datasource.type Value: org.apache.tomca...2018-07-03 15:12:2533544
4
-
原创 Cannot find template location(s): [classpath:/templates/]
SpringBoot 项目启动后,可能在控制台看到这样一个警告:WARN 8904 --- [ restartedMain] o.s.b.a.f.FreeMarkerAutoConfigurationCannot find template location(s): [classpath:/templates/] (please add some templates, check your F...2018-07-04 17:01:4631984
5
-
原创 The remote endpoint was in state [TEXT_FULL_WRITING] which is an invalid state for called method
遇到该问题的代码,请参考:spring boot Websocket(使用笔记)当使用getAsyncRemote 的方式,也就是异步的方式发送消息的时候,导致该问题的产生;产生该问题的原因是什么?看一些文章中说是因为异步调用,但没有加锁,导致一个Session正在使用中,又被另一个线程调用;解决方法:就是添加synchronized 关键字;那么这和getBasi...2019-03-06 11:03:283695
2
-
转载 spring boot Websocket(使用笔记)
转自:spring boot Websocket(使用笔记)本文只作为个人笔记,大部分代码是引用其他人的文章的。在springboot项目中使用websocket做推送,虽然挺简单的,但初学也踩过几个坑,特此记录。 使用websocket有两种方式:1是使用sockjs,2是使用h5的标准。使用Html5标准自然更方便简单,所以记录的是配合h5的使用方法。1、pom 核心是...2019-03-06 10:48:251661
0
-
原创 SpringBoot 项目不加载 application.properties 配置文件
SpringBoot 项目不加载 application.properties 配置文件产生原因:先是创建的SpringBoot2.几版本的项目,结果发现继续使用1.几版本的配置会有很多的问题,于是在pom.xml中把版本改回了1.5.9,然后发现项目启动时并不会加载 application.properties 配置文件。在下图中可以发现,SpringBoot2.几版本的 resou...2019-01-16 11:40:1612255
0
-
原创 spring-boot日志配置 logging.path logging.file 注意事项
springboot日志配置 logging.path logging.file 注意事项可能有些小伙伴会同时配置 logging.path 和 logging.file,但是又发现其中一个不生效。官方文档中有这么一句:If you want to write log files in addition to the console output youneed to set a...2019-01-11 17:47:5334782
1
-
原创 Spring Boot org.springframework.beans.factory.BeanNotOfRequiredTypeException
遇到这个问题,有几种可能:1、项目打包的时候 mapping.xml 没有打包进去 2、项目打包的时候,配置文件没有打包进去检查:看看项目的“WEB-INF/classes”目录下,有没有配置文件。完整目录示例:E:\Deploy\apache-tomcat\webapps\ROOT\WEB-INF\classes 3、启用事务处理,但没有做AOP相关配置参考:...2019-01-10 17:12:15980
0
-
原创 Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by se
Consider injecting the bean as one of its interfaces or forcing the use of CGLib-based proxies by setting proxyTargetClass=true on @EnableAsync and/or @EnableCaching.问题描述Spring Boot 项目,启用事务支持时出现以下...2018-12-28 14:51:0316650
5
-
原创 maxIdle is larger than maxActive, setting maxIdle to: 20
WARN 6900 o.a.tomcat.jdbc.pool.ConnectionPool : maxIdle is larger than maxActive, setting maxIdle to: 20注意,这只是一个警告,你完全可以忽略它。但通过这个警告,让我加深了对 Spring Boot application.yml application.properties ...2018-09-26 14:48:565145
0
-
原创 No MyBatis mapper was found in xxx
SpringBoot 项目启动后输出了这样一个警告:WARN 8904 --- [ restartedMain] o.m.s.mapper.ClassPathMapperScanner : No MyBatis mapper was found in '[com.xxx]' package. Please check your configuration.很奇怪这个具体是在哪里配置的,...2018-07-05 10:56:5422078
4
-
原创 SpringBoot 项目 ajax post 出现 400 Bad Request 错误 后台调试不进断点的解决方法
在使用Ajax的时候,你可能遇到莫名其妙的的错误,这时你需要学会使用开发者工具来查看并定位、解决问题。与这个问题相关的,你也可以参考: POST 400 Bad Request The request sent by the client was syntactically incorrect最近有小伙伴问到:用ajax的时候,请求的路径是对的,但是始终进入不了这个方法,是什么原因,你有没有遇到过...2018-04-25 10:29:348244
1
-
原创 SpringBoot 项目 @EnableWebMvc 注解应用总结
SpringBoot 项目中不管是在哪个类上使用 @EnableWebMvc 注解,都将导致所有URL访问时返回 404 错误;看到一篇文章:“Spring4 @EnableWebMvc 纯注解启动”,但还没有在 Spring MVC 项目上尝试过。另外参考文章:“解析@EnableWebMvc 、WebMvcConfigurationSupport和WebMvcConfigurationAdap...2018-05-09 14:29:4840696
14
-
转载 spring boot修改代码后无需重启设置,在开发时实现热部署
Spring Boot在开发时实现热部署(开发时修改文件保存后自动重启应用)(spring-boot-devtools)热部署是什么大家都知道在项目开发过程中,常常会改动页面数据或者修改数据结构,为了显示改动效果,往往需要重启应用查看改变效果,其实就是重新编译生成了新的Class文件,这个文件里记录着和代码等对应的各种信息,然后Class文件将被虚拟机的ClassLoader加载。而热部署正是利用...2018-04-13 15:43:0418989
4
-
原创 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
完整错误信息:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.wanyu.fams.dao.BaseAreaMapper.selectByExample at org.apache.ibatis.binding.MapperMethod$SqlCommand.(MapperMe2018-01-08 17:45:392867
3
-
原创 org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.wan
完整错误信息:org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.xxx.xxx' available: expected at least 1 bean which qualifies as autowire candidate. Dependency a2018-01-08 17:45:273173
0
-
原创 Overriding managed version 5.1.44 for mysql-connector-java
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px '.SF NS Text'}Overriding managed version 5.1.44 for mysql-connector-javaSpring Boot 项目覆盖的较高的版本引用,把版本号删除了就行。Spring Boot 会自动查找匹配最合适的版本。2018-01-08 17:44:058055
0
-
转载 Spring Boot Actuator监控端点小结
在Spring Boot的众多Starter POMs中有一个特殊的模块,它不同于其他模块那样大多用于开发业务功能或是连接一些其他外部资源。它完全是一个用于暴露自身信息的模块,所以很明显,它的主要作用是用于监控与管理,它就是:spring-boot-starter-actuator。spring-boot-starter-actuator模块的实现对于实施微服务的中小团队来说,可以有效地减少监控系2018-01-12 17:38:371991
2
-
原创 Spring Boot Controller 无法访问 type=Not Found, status=404
Spring Boot 项目启动日志2017-09-26 14:23:08.443 INFO 3543 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : Looking for @ControllerAdvice: org.springframework.boot.context.embedded.Annotatio2017-09-26 14:28:087409
3
-
原创 java.io.IOException: Server returned HTTP response code: 403 for URL: http://start.spring.io
403 Forbidden 是HTTP协议中的一个状态码(Status Code)。可以简单的理解为没有权限访问此站。主要原因分析1.你的IP被列入黑名单2.你在一定时间内过多地访问此网站(一般是用采集程序),被防火墙拒绝访问了3.网站域名解析到了空间,但空间未绑定此域名4.你的网页脚本文件在当前目录下没有执行权限5.在不允许写/创建文件的目录中执行了创建/写文件操作6.以http方式访问需要ssl连接的网址7.浏览器不支持SSL 128时访问SSL 128的连接8.在身份验证的过程中输2017-12-29 17:47:0627537
2
-
原创 An internal error occurred during: "Building UI model". com/google/common/base/Function
An internal error occurred during: "Building UI model". com/google/common/base/FunctionEclipse Neon.2 Release (4.6.2) 安装了 STS(Spring Tool Suite) 后,创建项目时遇到些问题。错误原因:STS 版本与 Eclipse 版本不匹配。解决方法:1、下载正确的版本进2017-12-14 09:31:084956
3
-
原创 Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean.
自己新建的Maven 项目,然后通过修改 pom.xml 转为 Spring Boot 项目,出现此问题。启动日志如下:org.springframework.context.ApplicationContextException: Unable to start embedded container; nested exception is org.springframework.context2018-01-08 17:47:021522
2
-
原创 Binding to target org.springframework.boot.autoconfigure.jdbc.DataSourceProperties@46c3a14d failed:
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545}p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545; min-height: 14.0px}span.s12018-01-08 17:47:4116215
1
-
原创 Spring Boot Controller 返回jsp页面结果404
Spring Boot Controller 返回jsp页面结果404例如:@Controllerpublic class LoginBackController { public LoginBackController() { // TODO Auto-generated constructor stub } @RequestMapping("/loginback")...2018-03-27 10:26:296781
7
-
原创 Circular view path xxx would dispatch back to the current handler URL
Spring Boot 项目整合jsp支持,看了那么多介绍的文章全部都是需要后端Controller;尝试将 view 路径配置为:spring.mvc.view.prefix=/而后端 Controller return "loginback"; @RequestMapping("/loginback") public String index(Map<String,Objec...2018-03-26 16:50:0812735
2
-
转载 Spring Boot 使用JSP时,修改JSP不生效,需要重启的问题
问题描述 公司项目用的Spring Boot,自己也就对他多研究一些,之前自己练习的Spring Boot项目,都是使用的JSP,在修改后直接刷新页面就可以看到效果,今天升级Spring Boot版本后,发现修改JSP后直接刷新页面没有用了。。。重启才能生效。。。问题定位 什么问题都抵不住爱折腾的心,我原以为更换了IDE(试了试IDEA这个工具)导致的,换回原来的Eclipse惊奇的发现也是无效的...2018-02-11 13:40:023722
3
-
原创 Spring Boot application.yml application.properties 优先级
application.yml application.properties prioritystackoverflow 上有个问题是:Can application.properties and application.yml be mixed? Spring Boot 虽然做了大量的工作来简化配置,但其配置依然是相当的复杂!支持的外部配置方式就高达 17 种之多,当然这很灵活,...2018-01-09 12:31:3520492
14
-
原创 org.springframework.web.HttpMediaTypeNotSupportedException: Unsupported Media Type, status=415
org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'null' not supportedp.p1 {margin: 0.0px 0.0px 2.0px 0.0px; font: 14.0px 'Helvetica Neue'; color: #454545}p.p2 {margin: 0.0px 02018-01-08 17:43:0139479
0
-
原创 application.properties 文件和 application.yml 文件有什么区别呢?
application.properties 文件和 application.yml 文件有什么区别呢?yml文件的好处,天然的树状结构,一目了然,实质上跟properties是差不多的。官方给的很多demo,都是用yml文件配置的。注意点:1,原有的key,例如spring.jpa.properties.hibernate.dialect,按“.”分割,都变成树状的配置2,key后面的冒号,后2018-01-03 11:57:5960330
0
-
原创 java.lang.ClassCastException: com.mysql.jdbc.Driver cannot be cast to javax.sql.DataSource
错误描述:Spring Boot 项目启动时出现错误:java.lang.ClassCastException: com.mysql.jdbc.Driver cannot be cast to javax.sql.DataSource完整错误信息:org.springframework.beans.factory.BeanCreationException: Error creating bean2018-01-08 17:48:4410002
0
-
原创 Cannot load driver class: com.mysql.jdbc.Driver
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545}Cannot load driver class: com.mysql.jdbc.Driver看到类似的错误应该想到缺少Jar包引用。或者是你添加了依赖,却没有更新项目,Jar包没有下载到本地。解决方案一:普通项目:需要手动添加驱2018-01-08 17:48:20525
0
-
原创 ConflictingBeanDefinitionException: Annotation-specified bean name 'errorPageFilter'
Idea CE 下创建的基于 maven 的 Spring Boot 项目,在使用 命令启动时出现错误。完整错误信息:[ERROR] Failed to execute goal org.springframework.boot:spring-boot-maven-plugin:1.4.3.RELEASE:run (default-cli) on project testboot: An exc2017-09-04 18:55:0811285
0