Mybatis Dynamic SQL

1. If <select id="findActiveBlogWithTitleLike" resultType="Blog"> SELECT * FROM BLOG WHERE state = ‘ACTIVE’ <if test="title != null"> AND title like #{title} </if> </select> 2. Choose, When, Otherwise <select id="findActiveBlogLike" resultType="Blog"> SELECT * FROM BLOG WHERE state = ‘ACTIVE’ <choose> # choose only one case among many options <when test="title != Read more

Mybatis foreach tag

Six Attributes collection: There are three formats: list, array, and map, according to the type of parameter passed. item: the parameter name of the set of objects in the tag. separator: the separator at the end of each sub-loop, usually “,”. open: start character, often “(“. close: end character, often Read more

A Template of JUnit5 with Mockito

@ExtendWith(MockitoExtension.class) class ArticleManagerTest { @Mock ArticleDatabase database; @Mock User user; @Spy @InjectMocks private ArticleManager manager; @BeforeEach void setup(){ // some initialization codes } @Test void shouldDoSomething() { // TODO perform some tests with this managers when(database.some(param)).thenReturn(data); Object res = manager.exe(); assertEquals(res, "data"); verify(database).some(param); } } Reading more: Unit tests with Read more

MySQL Strings Segmentation

SUBSTRING_INDEX(str, delim, count) str: the string to be split. delim: the delimiter. count: the position of the delimiter. A positive number means extract from left to right, a negative number means extract from right to left. For example: SELECT SUBSTRING_INDEX('100-200-300-400', '-', 1); — output: '100' SELECT SUBSTRING_INDEX('100-200-300-400', '-', 2); — Read more

Gradle Dependency Collision Resolution

Today I met this error when build my project. SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/D:/apps/… fbb0e/logback-classic-1.2.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/D:/apps/… eca4e/slf4j-log4j12-1.7.6.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [ch.qos.logback.classic.util.ContextSelectorStaticBinder] I find that this is a dependency collision which Read more

Nginx Installation

Official website: http://nginx.org/ Click Download. Choose version campatible with your system. In this article, my system is Linux. Nginx is written in C language. So make sure you have C language environment first. yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel Unzip the software package. tar -zxvf nginx-1.10.0.tar.gz Read more

Strapi v4 Parameters

Strapi is an open-source headless CMS that gives developers the freedom to choose their favorite tools and frameworks and allows editors to manage and distribute their content using their application’s admin panel. API parameters can be used in conjunction with the REST API to filter, sort, and page results, as Read more

Catalogue