Overview Spring中@Import注解最初主要是在配置类中使用,目的是引入其他的配置类(@Configuration)并实现自动注入。 目前Import并不只是支持引入@Configuration注解的类,也支持引入Import
[阅读更多...]-
SpringBoot探索01 – @Import注解
-
CaffeineCache 慎用weakKeys
前两天在一个Spring项目里使用了Caffine缓存,在application.yml中的配置如下: cache: type: CAFFEINE caffeine: spec: initialCapacity=1048576,maximu
[阅读更多...] -
Spring Controller层测试 – 05 SpringBootTest & WebServer
在使用@SpringBootTest测试时可以指定一个端口,如@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT) 或 @SpringBootTest(webEnviron
[阅读更多...] -
Spring Controller层测试 – 04 SpringBootTest & MockMVC
这种测试方案会加载完整的SpringContext,但我们仍然不需要Web Server,需要继续通过MockMVC来模拟请求。 在测试的时候主要用到了@SpringBootTest注解。看下代码: @RunWith(SpringRunne
[阅读更多...] -
Spring Controller层测试 – 03 WebContext & MockMVC
这种Controller层测试方案会(部分)加载Spring Application Context。不过仍然还是主要是用MockMVC来进行测试,也不需要部署WebServer。 示例代码如下: @RunWith(SpringRunner
[阅读更多...] -
Spring Controller层测试 – 02 Standalone MockMVC
在Spring中,可以在Standalone模式下使用MockMVC来进行服务内测试,此时我们不会加载任何Context。来看个例子: @RunWith(MockitoJUnitRunner.class) public class Work
[阅读更多...] -
Spring Controller层测试 – 01 概述
Spring Controller层(Web层或API层)的测试有多种方案。有人倾向于使用纯单元测试,有人则倾向于使用集成测试。 单元测试和集成测试 先来看一下单元测试和集成测试的概念。 单元测试 单元测试是对软件中的最小可验证单元进行检查
[阅读更多...] -
WordPress java操作库
前段时间有些需求就撸了个wordpress java操作库,主要是依赖wordpress XMLRPC实现。简单介绍下使用方式。 引入dependency: <dependency> <groupId>org.cho
[阅读更多...] -
Java 中文字符按Unicode排序
遇到了一个对包含中文的字符串进行排序的问题。要求按unicode编码对字符串进行排序。 测试字符串数组如下: String[] arr = { “1-测试”, “1-编辑”, “1-营销”, “1结束”, “2-测试”, “1-qt” };
[阅读更多...] -
解决PKIX:unable to find valid certification path to requested target
遇到了“unable to find valid certification path to requested target”这样的问题。 错误详情如下: at sun.security.ssl.SSLSocketImpl.startHa
[阅读更多...]