java
国家一级保护程序员
这个作者很懒,什么都没留下…
展开
-
springboot项目如何整合mybatis-plus与pagehelper分页插件的使用
加入依赖<dependency> <groupId>com.github.pagehelper</groupId> <artifactId>pagehelper-spring-boot-starter</artifactId> <version>1.2.13</version> <exclusions>原创 2022-01-15 10:24:06 · 271 阅读 · 0 评论 -
java两个数相除,如何返回一个百分数(如包含百分号“70%”)
java.text包有一个NumberFormat类,将两个数计算,最后的返回结果为String类型,包含“%”。private String getRatio(Double d1, Double d2) { if (d1 == null || d2 == null || d2 <= 0) { return "0%"; } NumberFormat percent = NumberFormat.g原创 2021-03-22 15:45:19 · 2167 阅读 · 0 评论 -
java算数异常Non-terminating decimal expansion; no exact representable decimal result.
使用Decimal 类型,调用divide()方法做除法,一直报java.lang.ArithmeticException: Non-terminating decimal expansion; no exact representable decimal resultnum.divide(number);原来JAVA中如果用BigDecimal做除法的时候一定要在divide方法中传递第二个参数,定义精确到小数点后几位,否则在不整除的情况下,结果是无限循环小数时,就会抛出以上异常。解决方法:/*原创 2021-03-12 14:48:30 · 422 阅读 · 0 评论 -
spring boot集成shiro,配置ShiroConfig类相关继承org.apache.shiro.spring.web的类@Autowired无法注入问题
这个问题真的折磨我很久,在网上找了很多方法都解决不了幸好看见了这一篇https://www.cnblogs.com/matd/p/11128179.html原创 2020-09-29 16:24:27 · 958 阅读 · 0 评论 -
类加入了@Component注解,但启动时在别的@Configuration类中@Autowired注入为null
最近更新spring boot项目遇到这么一个问题,自己写的一个类明明加上了@Component注解按理说加入了容器中,但在启动时报空指针异常,结果bebug发现@Autowired注入为null。在网上找了很久都没有找到解决办法。应该是在注入的时候,bean还没有初始化解决办法:1.通过自己new对象加入到bean容器中 @Bean AuthenticationRealm injectRealm(){ AuthenticationRealm authentic原创 2020-09-10 16:05:26 · 2169 阅读 · 0 评论