spring
文章平均质量分 61
Wheat_Liu
戒骄戒躁,学无止境
展开
-
Spring原理解读——事务传播行为
Spring原理解读——事务传播行为写在前面不要使用junit等测试方法测试事务,spring会自动回滚事务不要把不同事务写在同一个类里,这样无法打到事务嵌套的测试效果请手动回滚,不要尝试向上层抛出异常准备工作maven依赖<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter原创 2021-09-14 22:31:58 · 354 阅读 · 0 评论 -
Spring源码解读——启动流程refresh
Spring源码解读——启动流程准备工作maven依赖<dependency> <groupId>org.springframework</groupId> <artifactId>spring-context</artifactId> <version>5.3.7</version></dependency>一个普通类public class TestBean {}原创 2021-09-13 16:30:36 · 332 阅读 · 0 评论 -
nacos升级spring cloud 2020.0无法使用bootstrap.yml的问题
之前用spring cloud整合nacos,需要一个bootstrap.yml作为spring启动的初始化配置bootstrap.yml内容大概如下:spring: application: # 应用名称 name: xxx profiles: active: dev cloud: nacos: config: file-extension: yml server-addr: localhost:8848原创 2021-05-25 10:58:31 · 1610 阅读 · 8 评论 -
springboot整合shiro、ehcache
只需要一个自定义realm、一个shiro配置类和ehcache自定义realm:package com.example.demo.config;import com.example.demo.entity.RoleEntity;import com.example.demo.entity.UserEntity;import com.example.demo.jpa.UserJp...原创 2018-10-16 22:13:10 · 769 阅读 · 0 评论 -
Cannot deserialize session attribute [SPRING_SECURITY_CONTEXT] for session的解决办法
在SpringBoot整合SpringSecurity,并启用devtools的时候,会抛出如下异常:Cannot deserialize session attribute [SPRING_SECURITY_CONTEXT] for session [xxx]提示是无法序列化session,根据stackoverflow上的答案只要在你序列化自定义的UserDetials类中传入的...翻译 2019-03-11 19:16:00 · 2743 阅读 · 0 评论 -
springboot整合spring security
本文主要实现:基于数据库的用户登录认证授权(基于内存的没研究)基于cookie的remember me记住我的功能先上代码,再说明:maven:其中验证码用的google code kaptcha,需要自己去maven仓库下载jar包install进自己的仓库,直接用maven配置是无法下载的<!-- 安全框架 Spring Security --> ...原创 2019-02-26 14:39:05 · 256 阅读 · 0 评论 -
idea 创建springboot工程
步骤如图原创 2018-09-13 10:38:31 · 184 阅读 · 0 评论 -
springboot + ajax 简单交互
项目结构如图所示,由于没有使用thymeleaf模版所以删掉了文件夹:前端页面代码:登录页:<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Title</title></head><...原创 2018-09-14 17:31:02 · 16873 阅读 · 0 评论 -
SpringBoot单元测试
@RunWith(SpringRunner.class)@SpringBootTest(classes = DemoApplication.class)public class TestClass { @Autowired private UserService userService; @Test public void test(){ ...原创 2019-05-17 09:34:37 · 220 阅读 · 0 评论 -
springboot日期格式问题
在使用@RestController或@ResponseBody后,接口会把数据格式化为json,同时日期也会格式化成这种2019-05-22T16:00:00.000+0000解决方法:在application.properties中添加配置#时间格式化spring.jackson.date-format=yyyy-MM-dd HH:mm:ss#时区spring.jac...原创 2019-05-24 22:11:26 · 450 阅读 · 0 评论 -
undertow警告Buffer pool was not set on WebSocketDeploymentInfo
看提示让你设置一下buffer pool,不然他就使用默认的这个警告不影响使用,但是看着别扭,于是根据官方文档,和源码,自定义配置/** * 功能描述: * * @author liuchaoyong * @version 1.0 * @date 2019-05-26 21:41 */@Componentpublic class CustomizationBean i...原创 2019-05-26 23:08:15 · 12606 阅读 · 1 评论 -
@RequestBody接收json对象报415的解决办法
前端请求:$.ajax({ url: basePath() + "/index/login.do", type : "post", data: JSON.stringify(form), dataType : "json", contentType : "applicati...原创 2018-08-25 23:13:49 · 5993 阅读 · 3 评论 -
@RequestBody和@RequestParam的区别
先上代码,再说区别:前端:使用@RequestParam:主要处理contentType为application/x-www-form-urlencoded的数据(默认)<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title&原创 2018-10-10 14:19:49 · 4841 阅读 · 1 评论 -
spring异步调用
问题应用背景: 最近在做一个有文件管理功能的网盘,要求office文件上传后转码,转码用的LibreOffice。众所周知转码非常耗时,如果转码和添加用户文件数据放在一个方法里,会导致前端等待后端返回数据耗时较长,用户体验变差,于是想到让转码和添加用户文件数据异步执行。框架:SSM在spring.xml中加入如下代码:<?xml version="1.0"...原创 2018-12-26 09:35:57 · 246 阅读 · 0 评论 -
spring定时任务
框架背景:ssm在spring整合mvc的配置文件(我的叫spring-mvc.xml)中加入:xmlns:task="http://www.springframework.org/schema/task"http://www.springframework.org/schema/taskhttp://www.springframework.org/schema/task/sprin...原创 2018-09-27 14:49:16 · 90 阅读 · 0 评论 -
tomcat启动报错AnnotationConfigBeanDefinitionParser are only available on JDK 1.5 and higher
项目环境:struts 2.1.8 + hibernate 3.3.2 + spring2.5 + jdk8 + tomcat8.5.20错误原因:老项目使用spring2.5版本默认支持jdk5以上,可能是spring2.5的bug导致jdk8不被spring识别解决办法:换成jdk6或者7即可,如果你用的tomcat版本为8及以上,那就只能使用jdk7了...原创 2018-09-04 09:49:44 · 300 阅读 · 0 评论