2022年3月21日 星期一

JPA API和Hibernate API的對照

  JPA API                                      Hibernate API
---------------                                  --------------------
 EntityManagerFactory                SessionFactory
 EntityManager                            Session
 EntityTransaction                        Transaction
 Query                                          Query

2022年3月3日 星期四

微服務的容錯處理規範:Microprofile Fault Tolerance

Quarkus有實做Microprofile規範的容錯處理(採用SmallRye) 
Spring Cloud以前會使用Netflix Hystrix的方案,但是Hystrix已經停止開發了(只維護)
SpringCloud在2020之後的版本也已經移除spring-cloud-netflix,改推薦使用Resilience4j


Microprofile Fault Tolerance的規格
https://download.eclipse.org/microprofile/microprofile-fault-tolerance-1.1.2/microprofile-fault-tolerance-spec.html

Spring和MicroProfile解決方案比較表
https://www.eclipse.org/community/eclipse_newsletter/2019/september/microprofile.php

2022年3月2日 星期三

Error creating bean with name 'dataConfig': Invocation of init method failed; nested exception is java.awt.HeadlessException

System.setProperty("java.awt.headless", "false");
//DatabaseManagerSwing前面加紅色這一行
DatabaseManagerSwing.main(new String[] { "--url", "jdbc:hsqldb:mem:testdb", "--noexit" });


完整錯誤訊息:
Caused by: java.awt.HeadlessException: null
        at java.desktop/java.awt.GraphicsEnvironment.checkHeadless(GraphicsEnvironment.java:166) ~[na:na]
        at java.desktop/java.awt.Window.<init>(Window.java:553) ~[na:na]
        at java.desktop/java.awt.Frame.<init>(Frame.java:428) ~[na:na]
        at java.desktop/java.awt.Frame.<init>(Frame.java:393) ~[na:na]
        at java.desktop/javax.swing.JFrame.<init>(JFrame.java:180) ~[na:na]
        at org.hsqldb.util.DatabaseManagerSwing.<init>(Unknown Source) ~[hsqldb-2.6.1.jar:2.6.1]
        at org.hsqldb.util.DatabaseManagerSwing.main(Unknown Source) ~[hsqldb-2.6.1.jar:2.6.1]

The bean 'localeResolver', defined in class path resource

在組態檔application.properties加入以下設定
spring.main.allow-bean-definition-overriding=true

參考
https://stackoverflow.com/questions/63658346/a-bean-with-that-name-has-already-been-defined-in-class-path-resource-path-and


完整錯誤訊息:
The bean 'localeResolver', defined in class path resource [com/aabbcc/config/WebConfig.class], could not be registered. A bean with that name has already been defined in class path resource [org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration.class] and overriding is disabled.