// where type = 1 or type = 2 wrapper.and(wrapper -> wrapper.eq("type", 1) .or().eq("type", 2))
// find_in_set(?, category_id) or find_in_set(?, category_id) queryWrapper.and(wrapper -> { for (inti=0; i < categoryIds.size(); i++) { if (i > 0) { wrapper.or(); } wrapper.apply("find_in_set({0}, category_id)", categoryIds.get(i)); } return wrapper; });
// where status = 0 and (type = 1 or (type > 10 and type < 20)) wrapper.eq("status", 0) .and(wrapper -> wrapper.eq("type", 1) .or(wrapper2 -> wrapper2.gt("type", 10) .lt("type", 20));
Pass com.baomidou.mybatisplus.extension.plugins.pagination.Page object as a parameter.
Using the IPage class as the return type.
Don’t need to add limit start, size in mapper XML. The SQL is query all rows. But MyBatis Plus automatically add limit at the end of SQL. If you want to query all, update to List<MyResult> queryAll(@Param("param") MyParam param);
Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'spring.datasource.druid.initialSize' in value "${spring.datasource.druid.initialSize}" at org.springframework.util.PropertyPlaceholderHelper.parseStringValue(PropertyPlaceholderHelper.java:178) ... 97 common frames omitted
Solutions
1. Check that the property you need exists in a configuration file. Find out in which configuration file your injected property is.
2. Check whether the property spring.profiles.active value is correct in application.yml. Make sure the active profile is in your project.
3. Check whether your injected property exists in application.yml (or application.properties) and the active profile application-xxx.yml (or application-xxx.properties).
Reasons
The value of the property spring.profiles.active in my application.yml is spring.profiles.active=pro, but I don’t have the application-pro.yml file. The property’s value spring.profiles.active=pro should update to prod.
Java’s standard java.net.URL class and standard handlers for various URL prefixes unfortunately are not quite adequate enough for all access to low-level resources. For example, there is no standardized URL implementation that may be used to access a resource that needs to be obtained from the classpath, or relative to a ServletContext. While it is possible to register new handlers for specialized URL prefixes (similar to existing handlers for prefixes such as http:), this is generally quite complicated, and the URL interface still lacks some desirable functionality, such as a method to check for the existence of the resource being pointed to.
Time cost: BufferedInputStream + Direct Buffer array < Direct Buffer array < Using a BufferedInputStream < Read Method.
Using BufferedInputStream rather than direct buffer is probably “right” for most applications. Because your used buffer size of direct buffer may be worse than BufferedInputStream default buffer size in speed.
Will making the buffer bigger make I/O go faster? Java buffers typically are by default 1024 or 2048 bytes long. A buffer larger than this may help speed I/O, but often by only a few percent, say 5 to 10%.
Problems
Max upload file size
Character encoding of file name
URL encode of file name
Appendixes
Temporary Files and Directories
java.io.tmpdir
System.getProperty("java.io.tmpdir")
Windows 10: C:\Users\{user}\AppData\Local\Temp\
Debian: /tmp
Create temporary file
// If you don't specify the file suffix, the default file suffix is ".tmp". Filefile= File.createTempFile("temp", null); System.out.println(file.getAbsolutePath()); file.deleteOnExit();
Two primary MIME types are important for the role of default types:
text/plain is the default value for textual files. A textual file should be human-readable and must not contain binary data.
application/octet-stream is the default value for all other cases. An unknown file type should use this type. Browsers pay a particular care when manipulating these files, attempting to safeguard the user to prevent dangerous behaviors.
MyBatis is a first class persistence framework with support for custom SQL, stored procedures and advanced mappings. MyBatis eliminates almost all of the JDBC code and manual setting of parameters and retrieval of results. MyBatis can use simple XML or Annotations for configuration and map primitives, Map interfaces and Java POJOs (Plain Old Java Objects) to database records.
MyBatis-Spring integrates MyBatis seamlessly with Spring. This library allows MyBatis to participate in Spring transactions, takes care of building MyBatis mappers and SqlSessions and inject them into other beans, translates MyBatis exceptions into Spring DataAccessExceptions, and finally, it lets you build your application code free of dependencies on MyBatis, Spring or MyBatis-Spring.
Today I try to delete a directory with 485,000+ files on Linux server. It shows the error message below.
/bin/rm: Argument list too long.
If you’re trying to delete a very large number of files in a single directory at one time, you will probably run into this error. The problem is that when you type something like rm -f /data/*. So how do we working with directories with a large number of files? Let talk about it below.
Show first files
To show first n files in the directory instead of to show all files.
ls -U | head -10
Count the number of files
ls -f | wc -l
Remove files
Using for Loop
for f in *.pdf; do echo rm "$f"; done for f in *.pdf; do rm "$f"; done
Using Find
Using find -delete. (2000 files/second, it is about three time faster rm)
find . -maxdepth 1 -type f -name "$.split-*" -print -delete
Using find and xargs. To find every file and pass them one-by-one to the “rm” command (not recommend, xargs is dangerous*)