一些工具类
发表于|更新于
|浏览量:
自己收集的。。。
相关推荐
2022-02-26
Files.delete
终点线只是一个记号而已,其实并没有什么意义,关键是这一路你是如何走的。——村上春树 在java中我们除了用这种方式删除文件: 12345678File file = new File("D:\\file\\projects\\img-comparison-demo\\target\\generated-sources");if (file.exists()) { try { boolean delete = file.delete(); } catch (Exception e) { e.printStackTrace(); }} 还可以使用Files工具类: 12345try { boolean delete = Files.deleteIfExists(Paths.get("D:\\file\\projects\\img-comparison-demo\\target\\generated-sources"))...
2023-10-20
spring3 springfox报错Type javax.servlet.http.HttpServletRequest not present
相信一切,失望有日;怀疑一切,收获天明。——乔·赫伯特 就像这个issue里描述的一样: https://github.com/springfox/springfox/issues/4061 在springboot3.0引入: 12345 <dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version></dependency> 引入完毕后发现启动报错。。。于是查询了下 最后一次更新是三年前。。。 https://central.sonatype.com/artifact/io.springfox/springfox-boot-starter/versions 相对的springboot3是去年出的 https://central.sonatype.com/artifa...
2021-02-13
mybatis-plus实现多租户
我无论作什麽,始终在想着,只要我的精力允许我的话,我就要首先为我的祖国服务。——巴甫 个人理解的多租户:一套产品提供给多个企业使用,每家企业之间的数据相互隔离。例如我有一套运输管理系统,开发完成后,每一家企业购买我们的产品,我只需要提供一个账号,即可拥有完整的内容。如权限管理、订单管理等,他们之间的数据是不互通的 我们可以通过在每张表上加一个租户id去实现这个功能 我们的mybatis-plus版本为3.1.0,这里放上依赖 123456<!-- mybatis-plus --><dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-boot-starter</artifactId> <version>3.1.0</version></dependency> 然后我们需要修改配置文件 1234567891011#mybatis的配置mybatis-plus...
2020-12-28
中文转拼音
时间最不偏私,给任何人都是二十四小时;时间也最偏私,给任何人都不是二十四小时。──赫胥黎 引入依赖 12345<dependency> <groupId>com.belerweb</groupId> <artifactId>pinyin4j</artifactId> <version>2.5.0</version></dependency> 编写代码 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172package com.ruben.utils;import net.sourceforge.pinyin4j.PinyinHelper;import net.sourceforge.pinyin4j.format.HanyuPinyinCaseT...
2021-07-22
创建只读集合
真正的人生,只有在经过艰难卓绝的斗争之后才能实现。——塞涅卡 在java8中 我们可以使用下面的函数创建只读集合 12345678Collections.unmodifiableCollection(Arrays.asList(""));Collections.unmodifiableList(Collections.singletonList(""));Collections.unmodifiableMap(new HashMap<>(1 << 4));Collections.unmodifiableSet(new HashSet<>());Collections.unmodifiableNavigableMap(new TreeMap<>());Collections.unmodifiableNavigableSet(new TreeSet<>());Collections.unmodifiableSortedMap(new TreeMap<>());Colle...
2023-02-04
rewriteBatchedStatements
从前的日色变得慢,车,马,邮件都慢,一生只够爱一个人。——木心 我们在使用mybatis进行批量更新时,可以在mysql的链接url处添加rewriteBatchedStatements=true提升效率. 文档:https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-connp-props-performance-extensions.html 1rewriteBatchedStatements Should the driver use multi-queries, regardless of the setting of ‘allowMultiQueries’, as well as rewriting of prepared statements for INSERT and REPLACE queries into multi-values clause statements when ‘executeBatch()’ is called? Notice that this might allow SQL...
