
SpringBoot
poweljkflsabdfk
这个作者很懒,什么都没留下…
展开
-
springboot junit测试Controller接口
package com.atung.test;import java.net.URI;import org.junit.Before;import org.junit.Test;import org.junit.runner.RunWith;//import org.junit.jupiter.api.*;import org.springframework.beans.factory.annotation.Autowired;import org.springframework....原创 2021-02-03 14:21:18 · 1603 阅读 · 0 评论 -
springboot发送http请求
import org.springframework.http.HttpEntity;import org.springframework.http.HttpHeaders;import org.springframework.http.HttpMethod;import org.springframework.util.LinkedMultiValueMap;import org.springframework.util.MultiValueMap;import org.springfra...原创 2021-01-06 16:51:35 · 531 阅读 · 1 评论 -
springboot 访问api 测试
springboot 测试访问APIimport org.junit.Assert;import org.junit.Test;import org.junit.runner.RunWith;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.boot.test.context.SpringBootTest;import org.springframework.ht原创 2020-08-18 15:57:40 · 608 阅读 · 0 评论 -
springboot获取容器中的Bean
import org.springframework.beans.BeansException;import org.springframework.context.ApplicationContext;import org.springframework.context.ApplicationContextAware;import org.springframework.stereotype.Component;@Componentpublic class SpringUtil impl..转载 2020-05-22 15:12:07 · 1295 阅读 · 0 评论 -
springboot测试类编写
编写springboot测试类依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope>...原创 2020-04-17 16:47:44 · 913 阅读 · 0 评论 -
springboot REST风格接口
import java.util.List;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.web.bind.annotation.DeleteMapping;import org.springframework.web.bind.annotation...原创 2020-04-01 16:26:03 · 293 阅读 · 0 评论 -
springboot 配置 jsp
springboot项目配置jsp1,添加依赖 <!-- JSP --> <dependency> <groupId>org.apache.tomcat.embed</groupId> <artifactId>tomcat-embed-j...原创 2020-03-27 16:27:06 · 258 阅读 · 0 评论 -
Redis 触发器
Redis 触发器监听 Redis 中Key超时失效的事件Redis中的key可以设置生存时间,当该key超时失效时会触发一个事件“过期事件通过Redis的订阅与发布功能(pub/sub)来进行分发。”首先需要修改Redis 的配置文件,将notify-keyspace-events 的值改为 Ex1.监听程序import redis.clients.j...原创 2018-07-02 19:43:20 · 5644 阅读 · 0 评论 -
mybatis 二级缓存
配置(默认值是true,所以若设置值为true时可以不配置):mybatis.configuration.cache-enabled=true使用:在DAO(或mapper,添加@Mapper的类上)添加注解@CacheNamespace@CacheNamespace 属性:eviction:回收策略,默认LruCache(最近最少使用算法,使用时间距离现在最久的那个被移除...原创 2019-01-29 12:34:45 · 387 阅读 · 0 评论 -
spring 注解
@Autowired:注入Bean@Qualifier(value = "userServiceImpl"):指定注入的Bean,与@Autowired配合使用@Resource(name = "userServiceImpl"):注入指定的Bean @DateTimeFormat:时间类型格式化@NumberFormat:数字类型格式化 @PostConstruct...原创 2019-01-17 17:36:09 · 141 阅读 · 0 评论 -
springboot 监听器
package com.yuyi.listener;import javax.servlet.ServletRequestEvent;import javax.servlet.ServletRequestListener;import org.springframework.stereotype.Component;/** * request 请求监听器 */@Compone...原创 2019-01-17 16:25:41 · 242 阅读 · 0 评论 -
springboot 过滤器
package com.yuyi.filter;import java.io.IOException;import javax.servlet.Filter;import javax.servlet.FilterChain;import javax.servlet.FilterConfig;import javax.servlet.ServletException;import ...原创 2019-01-17 16:23:08 · 143 阅读 · 0 评论 -
springboot 拦截器
拦截器实现package com.yuyi.interceptor;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import org.springframework.web.servlet.HandlerInterceptor;import o...原创 2019-01-17 16:20:22 · 169 阅读 · 0 评论 -
springboot 使用RabbitMQ实现延迟队列
RabbitMQ延迟消息实现方式延迟任务通过消息的TTL和Dead Letter Exchange来实现。我们需要建立2个队列,一个用于发送消息,一个用于消息过期后的转发目标队列。生产者输出消息到Queue1,并且这个消息是设置有有效时间的,比如60s。消息会在Queue1中等待60s,如果没有消费者收掉的话,它就是被转发到Queue2,Queue2有消费者,收到,处理延迟任务。具...原创 2018-07-26 18:40:40 · 2282 阅读 · 0 评论 -
springboot 中使用缓存
1.配置在 pom.xml 中加入Ehcache 依赖 <!-- EHcache缓存 --> <dependency> <groupId>net.sf.ehcache</groupId> <artifactId>ehcache</artifact...原创 2018-06-05 14:13:38 · 812 阅读 · 0 评论 -
springBoot 获取配置文件配置内容
配置文件 src/main/resources 目录下:book.propertiesyuyi.book.name=三国演义yuyi.book.count=100一、使用@Value 注解注入属性package com.yuyi.bean.model;import org.springframework.beans.factory.annotation.Value;im...原创 2018-05-15 15:53:27 · 1070 阅读 · 0 评论 -
SpringBoot项目部署到Tomcat中
Spring Boot打成war包发布到Tomcat中。一、修改打包形式在pom.xml里设置 war二、移除嵌入式tomcat插件在pom.xml里找到spring-boot-starter-web依赖节点,在其中添加如下代码,org.springframework.bootspring-boot-starter-web原创 2018-01-30 11:37:40 · 7560 阅读 · 0 评论