"Your time is limited, so don't waste it living someone else's life"

Configuration ngoài cho ứng dụng với Spring Boot

1. Sử dụng properties file SpringApplication sẽ load các property từ tất cả các file application.properties trong các vị trí sau, và thêm chúng vào application environment: + Folder /config bên trong folder hiện tại. + Folder hiện tại. + Class path /config + Root class path Mặc định, SpringApplication sẽ load theo thứ tự từ dưới lên trên. Và các property nào load sau sẽ override property load trước. Vì lý do này, bạn cứ đặt property vào class path bình thường, khi muốn config ngoài file jar, thì sẽ đặt file application.properties vào folder /config là được. Như vậy cần phải build dự án với maven sao cho có kết quả trong folder target như sau:


Read more of this post

Sử dụng configuration class trong Spring Boot

1. Sử dụng class Configuration
Spring Boot ưu ái việc sử dụng các class Configuration. Mặc dù bạn có thể hoàn toàn sử dụng việc gọi hàm SpringApplication.run() ngay bên trong file XML, nhưng nhìn chung Spring khuyên điểm xuất phát của ứng dụng là một class với annotation @Configuration. Thông thường thì class với hàm main() thì nên là cũng là lớp chứa @Configuration.

import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Configuration;

public class Application
    public static void main(final String[] args)
        SpringApplication.run(Application.class, args);

Read more of this post

What is Hypervisor ?

What is Hypervisor?
Hypervisor (visor: còn gọi là tấm bảo vệ) là một software, firmware hay hardware giúp tạo và điều hành các máy ảo. PC mà trên đó hypervisor đang kiểm soát hoạt động của một hoặc nhiều máy ảo gọi là host machine. Mỗi máy ảo gọi là guest machine. Hypervisor kiểm soát các guest OS trên một nền tảng điều hành ảo (Virtual Operating Platform) và quản lý hoạt động của các hệ điều hành này. Các guest machine chia sẽ các hardware resource ảo.

Read more of this post

What you should do when the arrow keys is locked in eclipse on Linux platform

When I use Eclipse IDE on a Linux machine, I usually encounter some problems when the arrow keys suddenly loose their effect. The enter and backspace key also is stuck by this way. It makes me angry and I often press these key many times to try to get out of this obstacle.
After many attempts, I can reproduce the case when this problem occur by these steps: Hover your mouse on a function to make eclipse show up its java doc popup window. Then you move your mouse and click inside that window to focus on that one. After that, you move the mouse out the java doc window and click on anywhere in the editor. By this way, the problem happens.

As my opinion, this is simply caused by the loosing of focus on your editor. The focus is still on the popup window.

With that cause, I find out the way to make the focus back on the editor. You can do something like: show up any more popup window (by right click on editor and select Quick Outline for instance) and then press Esc, the focus will back immediately and you can use your arrow keys as usual.

For conclusion: Right Click (on editor) -> Quick Outline -> press Esc key.

Extract content and attachments from an Message use Javax mail (with embedded message EML, MSG)

The main part in a javax message is the content. The content can be any Java object representing the mail content, like a plain text (String) or raw image data or even a multiple part object. A multiple part content a message’s content consists of more than a single item. A multiple part object is a container which holds one ore more BodyPart objects. These BodyParts, like a message, have a content and a content type (in fact, both message and BodyPart implement the same interface Part which carries these properties).

Beside plain content, A BodyPart can contain another Multipart or even another Message, a so called nested message (e.g. a forwarded message, called embedded message) with content type ‘message/rfc822’.

As you can see, the structure of a message can be rather heterogeneous, a tree with nodes of different types. The following picture illustrates the tree structure for a sample message.
Read more of this post

Install plugins for eclipse Luna via dropins directory

The simple way you can install plugins for eclipse Luna is create an external dropins directory. In this dropins directory you can easily download plugins and extract it to each folder. You don’t need to do anything else. The dropins folder after contain 3 plugins: Windowbuilder, Checkstyle and Jautodoc have the structure as below:

And the only other thing you have to do is add a property contain the absolute path to your dropins directory into eclipse.ini file.


Searching algorithm DFS

Depth first search (DFS) is a searching algorithm used in searching maze.
A maze is also a graph with: a vertex equals a intersection, and edge is passage. (So, we should have some basic knowledge about graph, this will is be stored in some next posts)
The goal of using this algorithm in maze is explore all the connected intersections with a start point in the maze.
Algorithm for DFS:
+ Mark the visited intersection by a nut on the string.
+ Enter any passage related with that intersection that have never visit before and unroll the ball of string to mark that passage.
+ Retrace steps when no unvisited options.
Read more of this post

%d bloggers like this: