[Spring Boot] Logging trong Spring Boot

Spring Boot uses Commons Logging for all internal logging but leaves the underlying log implementation open. Default configurations are provided for Java Util LoggingLog4J2, and Logback. In each case, loggers are pre-configured to use console output with optional file output also available.

By default, if you use the “Starters”, Logback is used for logging. Appropriate Logback routing is also included to ensure that dependent libraries that use Java Util Logging, Commons Logging, Log4J, or SLF4J all work correctly.

Tiếp tục đọc

#spring-boot, #spring-framework

[Spring Boot] Testing trong Spring Boot

Spring Boot provides a number of utilities and annotations to help when testing your application. Test support is provided by two modules: spring-boot-test contains core items, and spring-boot-test-autoconfigure supports auto-configuration for tests.

Most developers use the spring-boot-starter-test “Starter”, which imports both Spring Boot test modules as well as JUnit, AssertJ, Hamcrest, and a number of other useful libraries.

Tiếp tục đọc

#spring-boot, #spring-framework

[Spring Data JPA] Xây dựng câu truy vấn thông qua tên của phương thức

Có nhiều cách khác nhau để tạo truy vấn với Spring Data JPA.

Creation from method names

Using JPA Named Queries

Using @Query

Mặc dù việc tạo truy vấn bằng cách Creation from method names khá là thuận tiện, nhưng vẫn có một số trường hợp cách này không phải là lựa chọn tối ưu. Ví dụ như trong quy tắc đặt tên phương thức không hỗ trợ một vài từ khóa SQL mà ta mong muốn, hoặc trường hợp câu truy vấn phức tạp thì tên phương thức sẽ rất dài nhìn hơi tởm 😀 Trong trường hợp đó các cách khác có thể là một lựa chọn hợp lý hơn.

Trong bài viết này sẽ chỉ nói về cách làm đầu tiên, tạo truy vấn thông qua tên của phương thức.

Tiếp tục đọc

#spring-data, #spring-data-jpa, #spring-framework

[Spring Boot] Danh sách các liên kết tham khảo

1. Official documentations

Spring Initializr

https://start.spring.io/

Spring Boot Reference Guide

https://docs.spring.io/spring-boot/docs/current/reference/html/

Appendix A. Common application properties

https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

#spring-boot, #spring-framework

[Spring Boot] Các thuộc tính cấu hình thông dụng của Spring Boot

Appendix A. Common application properties

Various properties can be specified inside your application.properties file, inside your application.yml file, or as command line switches. This appendix provides a list of common Spring Boot properties and references to the underlying classes that consume them.

https://docs.spring.io/spring-boot/docs/current/reference/html/common-application-properties.html

#spring-boot, #spring-framework

[Spring Data JPA] Tips

1. Spring Data JPA Auditing: Saving CreatedBy, CreatedDate, LastModifiedBy, LastModifiedDate automatically

https://programmingmitra.blogspot.com/2017/02/automatic-spring-data-jpa-auditing-saving-CreatedBy-createddate-lastmodifiedby-lastmodifieddate-automatically.html

 

 

#spring-data, #spring-data-jpa, #spring-framework

[Spring Boot] Tips

1. Spring Boot Performance

https://www.alexecollins.com/spring-boot-performance/

 

#spring-boot, #spring-framework