2021-05-12

netbeans 8 修復maven 及 plugin 問題

 新的maven要求https傳輸,所以需要升級maven:

1.下載新的maven:

http://maven.apache.org/download.cgi

2.解壓縮下載的檔案,放到netbeans安裝資料夾中的 java/maven 資料夾

3.在netbeans的jave/maven設定中,替換掉maven home

4.把 maven的conf/settings.xml的mirror區塊註解掉


然後netbeans 8的plugin portal的url發現已失效,可到以下頁面去找:
https://cwiki.apache.org/confluence/display/NETBEANS/Where+to+download+plugins+for+NetBeans+10.0+and+earlier

例如8.2: http://plugins.archive.librebeans.org/catalogue/8.2/catalog.xml

ref:

https://stackoverflow.com/questions/14026314/maven-location-when-installed-indirectly-with-netbeans-glassfish

https://oak.dev/2020/03/03/maven-error-return-code-is-501-reasonphrase-https-required/

2021-05-05

升級JDK 11.0.11後,無法正常使用TLS寄信

 ubuntu上面利用javax.mail寫的寄信程式,在系統自動升級jdk到 11.0.11 後,使用tls smtp寄信就失效了,經查是因為 jdk已禁用了 tls 1.0, tls 1.1,所以必須改強制使用 tls >= v1.2(很奇怪的點就是javax.mail握手時不會自動tls v1.2 or 1.3) ,當然你的mail server也要有支援 tls >= v1.2


            props.setProperty("mail.smtp.host", "your.smtp.server");

            props.setProperty("mail.smtp.auth", "true");

            props.setProperty("mail.smtp.port", "587");

            props.setProperty("mail.smtp.starttls.enable", "true");

            props.setProperty("mail.smtp.ssl.protocols", "TLSv1.2"); //強制tls v1.2

            Session session = Session.getDefaultInstance(props, new javax.mail.Authenticator() {

                @Override

                protected PasswordAuthentication getPasswordAuthentication() {

                    return new PasswordAuthentication("username", "password");

              }

            });

2021-03-17

phpmyadmin在innodb表格資料超過50000筆時,無法正確抓到筆數並切換頁

 

從phpmyadmin 4.8.0後,因效能考量,預設50000筆內是用select count取得資料列數,超過50000筆時才用show table status,但常會造成取的筆數不對,因此可以把phpmyadmin的$cfg['MaxExactCount']參數加大:

$cfg['MaxExactCountViews'] = 0;//disable trying to count the number of rows in any view
$cfg['MaxExactCount'] = 0;//disable correcting the InnoDB estimates

或者去點擊table總表的row count的數字去更新也行 (沒試過)

ref:
https://docs.phpmyadmin.net/en/latest/config.html#cfg_MaxExactCount
https://docs.phpmyadmin.net/en/latest/faq.html#faq3-11
https://stackoverflow.com/questions/10811405/phpmyadmin-and-big-tables
https://www.kavoir.com/2012/07/make-phpmyadmin-show-exact-number-of-records-for-innodb-tables.html

2021-03-04

netbeans在ubuntu上不斷要求開啟GNOME Keyring或KWallet 解決方法

 根據官方說明,這是netbeans用來記憶ftp, git, svn...等密碼的方法,就如同 window的login-based encryption、Mac OS X的Keychain、Linux的GNOME Keyring或KWallet。

解法一:安裝kwalletmanager或 libgnome-keyring-dev(擇一),並輸入你的使用者密碼讓netbneas有keyring或kwallet的存取權,以後就不會再來煩你了。

解法二:在netbeans.conf的netbeans_default_options加入:
-J-Dnetbeans.keyring.no.master=true
這樣以後密碼會存放在記憶體,但netbeans關掉就密碼就會消失了。

ref:

http://wiki.netbeans.org/FaqMasterPasswordDialog
https://wiki.archlinux.org/index.php/Netbeans#Integrate_Netbeans_with_kwallet
https://stackoverflow.com/questions/8666670/how-to-make-the-netbeans-doesnt-ask-for-the-master-password
https://superuser.com/questions/416976/why-does-netbeans-ask-for-master-password-at-the-begining

2021-03-03

ubuntu 強制移除套件

 sudo dpkg --purge --force-depends package-name

再用synaptic去修復損壞的套件

2021-02-25

tomcat 使用特殊字元網址或參數,造成400 bad request錯誤訊息

tomcat 使用特殊字元網址或參數,會造成400 bad request錯誤訊息,即使在web.xml設置error-page也無法禁止顯示系統報告(想不透...),需更改 server.xml,在<Host>加入:

<Valve className="org.apache.catalina.valves.ErrorReportValve" errorCode.0="conf/error.html" showReport="false" showServerInfo="false" />

其中 errorCode.0代表所有錯誤訊息,error.html 選擇使用$CATALINA_BASE相對路徑放在conf/error.html

ref:

https://stackoverflow.com/questions/794329/disable-all-default-http-error-response-content-in-tomcat

http://tomcat.apache.org/tomcat-9.0-doc/config/valve.html#Error_Report_Valve

2021-02-19

新專案上git時的必要前置設定

一、先產生.gitignore再做git init
例如你用的是netbeans的話,可以裝gitignore plugin或到這個網站,在專案的根目錄產生適合的.gitingore檔案,把不需要做版本控制的檔案(如build, dist等資料夾)排除。
可參考以下更詳細的.gitignore說明:
https://www.pluralsight.com/guides/how-to-use-gitignore-file
https://git-scm.com/docs/gitignore


二、設定gitconfig:
若一個專案的開發人員,不同人有著不同的OS平台,那麼 ~/.gitconfig (個人設定) 或 .git/config (專案設定,會覆蓋個人設定) 務必設定filemode = false及ignorecase = true

[user]

        email = username@yourmail.com

        name = username

[core]

        filemode = false #windows跟linux/macos開發者避免檔案權限錯誤訊息

        ignorecase = true #windows跟linux/macos開發者避免大小寫錯誤訊息

        autocrlf = false #false為不要自動轉換作業系統間的CRLF斷行,應以編輯器設定斷行字元。若設為input則checkout時會自動依平台轉換斷行,但commit時在linux/win一律為LF,在mac為CR



三、設定 .gitattributes
還要在repo的根目錄新增一個 .gitattributes 才解決跨平台換行(crlf)的衝突問題:

* text=auto eol=lf
*.{cmd,[cC][mM][dD]} text eol=crlf
*.{bat,[bB][aA][tT]} text eol=crlf
四、再做第一次的commit:
git commit -a -m "first commit, good luck!"