WebLogic timezone

測試人員發現,新增加進來的數據,某些人的生日出現了比實際生日少一天的問題。 如生日是 8-21,結果顯示在頁面上就變成了8-20,但有部份人員的生日又沒事,如12-26。 檢查數據庫數據都是正確的,并沒有少一天。但是數據庫的時區是+00:00,相關人員不肯修改數據庫時區。 因系統部署在WebLogic下,所以考慮修改應用服務器的時區設置。在Server-> Start配置中,為JVM參數,添加一個-Duser.timezone=GMT+8 問題解決。

为什么HashMap 默认loadFactor是0.75

As a general rule, the default load factor (.75) offers a good tradeoff between time and space costs. Higher values decrease the space overhead but increase the lookup cost (reflected in most of the operations of the HashMap class, including get and put). 大概意思是:一般来说,默认的负载因子(0.75)在时间和空间成本之间提供了很好的权衡。更高的值减少了空间开销,但增加了查找成本(反映在HashMap类的大多数操作中,包括get和put)。 试想一下,如果我们把负载因子设置成1,容量使用默认初始值16,那么表示一个HashMap需要在”满了”之后才会进行扩容。 那么在HashMap中,最好的情况是这16个元素通过hash算法之后分别落到了16个不同的桶中,否则就必然发生哈希碰撞。而且随着元素越多,哈希碰撞的概率越大,查找速度也会越低。 Others: HashMap默认容量为16根据HashMap的扩容机制,他会保证capacity的值永远都是2的幂。

SpringBoot 中使用Aop

前言 在Spring中,不管是学习还是面试,有两个点是永远绕不过去的,一个是IOC,另一个就是Aop,Spring中使用Aop是非常简单的,可以通过xml和注解两种方式写出aop的代码,那么在SpringBoot中有什么变化吗? 在SpringBoot中使用aop实际上没有太多的变化,关于SpringBoot实际上就是对Spring和SpringMVC的进一步封装,因此在 SpringBoot 中同样支持Spring框架中AOP切面编程,不过在SpringBoot中为了快速开发仅仅提供了注解方式的切面编程。 SpringBoot 注解式 aop 的使用 本文所有的内容,将会在下面的demo上进行操作。 请去Git仓库下载: https://gitee.com/bingqilinpeishenme/Lu-JavaNodes 1.引入依赖 <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId> </dependency> 2.aop相关注解讲解 /** @Aspect 用来类上,代表这个类是一个切面 @Before 用在方法上代表这个方法是一个前置通知方法 @After 用在方法上代表这个方法是一个后置通知方法 @Around 用在方法上代表这个方法是一个环绕的方法 @Order(数字)用在类上,数字越小进入越早 **/ /** 环绕,前置,后置全部存在 先进入环绕,在进入前置,离开前置,离开环绕,进入后置,离开后置 **/ 前置切面 /** * @Aspect 用来类上,代表这个类是一个切面 * @Component 用来告诉SpringBoot 给当前类创建对象 等价于@Service */ @Aspect @Component public class MyAspect { //@Before 用在方法上代表这个方法是一个前置通知方法 注解的参数是切点表达式 @Before(“execution(* com.lu.service.*.*(..))”) public […]

visitor

layout: pattern title: Visitor folder: visitor permalink: /patterns/visitor/ categories: Behavioral tags: – Gang of Four Intent Represent an operation to be performed on the elements of an object structure. Visitor lets you define a new operation without changing the classes of the elements on which it operates. Class diagram Applicability Use the Visitor pattern when […]

value-object

layout: pattern title: Value Object folder: value-object permalink: /patterns/value-object/ categories: Creational tags: – Instantiation Intent Provide objects which follow value semantics rather than reference semantics. This means value objects’ equality are not based on identity. Two value objects are equal when they have the same value, not necessarily being the same object. Class diagram Applicability […]

update-method

layout: pattern title: Update Method folder: update-method permalink: /patterns/update-method/ categories: Behavioral tags: – Game programming Intent Update method pattern simulates a collection of independent objects by telling each to process one frame of behavior at a time. Explanation The game world maintains a collection of objects. Each object implements an update method that simulates one […]

unit-of-work

layout: pattern title: Unit Of Work folder: unit-of-work permalink: /patterns/unit-of-work/ categories: Architectural tags: – Data access Intent When a business transaction is completed, all the these updates are sent as one big unit of work to be persisted in a database in one go so as to minimize database trips. Class diagram Applicability Use the […]

typeobjectpattern

layout: pattern title: Type-Object folder: typeobjectpattern permalink: /patterns/typeobjectpattern/ categories: Behavioral tags: Game programming – Extensibility Intent As explained in the book Game Programming Patterns by Robert Nystrom, type object pattern helps in Allowing flexible creation of new “classes” by creating a single class, each instance of which represents a different type of object Explanation Say, […]

twin

layout: pattern title: Twin folder: twin permalink: /patterns/twin/ categories: Structural tags: – Extensibility Intent Twin pattern is a design pattern which provides a standard solution to simulate multiple inheritance in java Class diagram Applicability Use the Twin idiom when To simulate multiple inheritance in a language that does not support this feature. To avoid certain […]

粤ICP备15017284号