随笔 - 232
文章 - 1
评论 - 28
阅读 -
60万
随笔分类 - springboot
org.springframework.data.redis.RedisSystemException: Redis exception; nested exception is io.lettuce.core.RedisException: java.io.IOException: Connection reset by peer
摘要:springBoot + redis. 程序隔一段时间会莫名其妙的报Redis的错误. 报错如下: org.springframework.data.redis.RedisSystemException: Redis exception; nested exception is io.lettuce
阅读全文
RESTful API 设计规范
摘要:一 URL设计 动词+宾语 动词的覆盖 宾语必须是名词 复数 URL 避免多级 URL 二、状态码 状态码必须精确 2XX状态码 3xx 状态码 4xx 状态码 5xx 状态码 三、服务器回应 不要返回纯本文 发生错误时,不要返回 200 状态码 提供链接 四、参考链接 RESTful 是目前最流行
阅读全文
springboot 读取Jar 类路径下的文件
摘要:只能用inputstream, 不能是file
阅读全文
将springboot打包成的jar文件做成windows服务
摘要:1.在idea中用maven将程序打成jar,放到运行的目录中。 2.去github上面下载winsw: https://github.com/kohsuke/winsw/releases 3. 将WinSW.NET4.exe文件复制到java程序所在文件夹中 4.将java程序重命名,去掉名称中的
阅读全文
spring springboot websocket 不能注入( @Autowired ) service bean 报 null 错误
摘要:spring 或 springboot 的 websocket 里面使用 @Autowired 注入 service 或 bean 时,报空指针异常,service 为 null(并不是不能被注入)。 解决方法:将要注入的 service 改成 static,就不会为null了。参考代码: 本质原因
阅读全文
springboot 通过docker 打包编译镜像
摘要:添加plugin <?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-instanc
阅读全文
springboot 解决 woff2、ttf 跨域无法解析问题
摘要:@Configuration public class CORSConfiguration extends WebMvcConfigurerAdapter { @Override public void addCorsMappings(CorsRegistry registry) { registry.addMapping("/**") ...
阅读全文
springboot 1.5.X junit测试
摘要:import org.junit.runner.RunWith; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.ju...
阅读全文
springboot 零xml集成mybatis-plus
摘要:工程结构 pom.xml application.properties MybatisPlusConfig.java UserMapper.java UserMapper.xml 源码
阅读全文
springboot 集合 meshsite3
摘要:工程目录 pom.xml 自定义过滤器,配置拦截规则, 加入web过滤器 编写web controller DecoratorController.java MeshsiteController.java 编写母版文件 default.html 编写被修饰文件 home.html 查看效果 http
阅读全文
springboot1.5.4 集成cxf完整实例
摘要:WebService 服务端 添加依赖 application.properties 服务接口 服务接口实现 发布服务 验证 WebService 客户端 添加依赖 测试代码 效果验证
阅读全文
springboot1.5.4 idea 自动保存编译更新
摘要:maven dependencies增加
阅读全文
springboot + shiro + cas4.2.7 实战
摘要:1. 下载地址 https://github.com/apereo/cas/archive/v4.2.7.zip 2. 解压后, 用intellj idea 打开 3. 执行 gradle build -x test ,打包编译 4. 取消https,能够支持直接http cas.propertie
阅读全文
springboot 中使用websocket简单例子
摘要:gradle 中添加依赖,引入websocket支持 启用websocket 消息拦截处理 消息处理相应类 前端js,需要依赖jquery
阅读全文
springboot 集成elasticsearh的简单配置
摘要:添加依赖 gradle 只要加入依赖后springboot就可以自动加载相关操作了,基本使用方式如下 application.properties 中可以配置es的一些动作,下面只列举部分,详细的可以看官网 下面列举一个简单例子,有使用了lombok要先在idea中安装插件才可以使用 只要简单的几个
阅读全文
springboot 自定义Repository
摘要:启用 JpaRepositories 在继承了 RdbCommonRepository 接口后, springboot会自动的在相同目录寻找他的实现类,规则是RdbCommonRepository+Impl 类命名规则,也可以手动指定,此处不做多解释,可以自行百度,一般不需要自行指定,使用方式如下
阅读全文
springboot redis 缓存对象
摘要:只要加入spring-boot-starter-data-redis , springboot 会自动识别并使用redis作为缓存容器,使用方式如下 gradle加入依赖 redis configuration 中启用缓存 redis 自定义key生成规则 有时候我们需要 使用 redisTempl
阅读全文
springboot 集成spring-session redis 实现分布式session
摘要:gradle 添加依赖 application.properties 配置redis信息 指定session 缓存方式 用RedisDesktopManager 查看redis缓存的session信息 搞定
阅读全文
springboot 集成shiro
摘要:首先看下shiro configuration 的配置,重要部分用红色标出了 自定义realm,用于认证和授权 自定义登出过滤器 自定义权限校验过滤器
阅读全文