Skip to content

Instantly share code, notes, and snippets.

View tuhin47's full-sized avatar
☠️

MD Towhidul Islam tuhin47

☠️
View GitHub Profile
@tuhin47
tuhin47 / notepad_plus_log4j.xml
Created November 18, 2020 04:55
notepad++ log4j extention
<NotepadPlus>
<UserLang name="Log4J" ext="log" udlVersion="2.1">
<Settings>
<Global caseIgnored="no" allowFoldOfComments="no" foldCompact="no" forcePureLC="0" decimalSeparator="2" />
<Prefix Keywords1="no" Keywords2="no" Keywords3="no" Keywords4="no" Keywords5="no" Keywords6="no" Keywords7="no" Keywords8="no" />
</Settings>
<KeywordLists>
<Keywords name="Comments">00 01 02 03 04</Keywords>
<Keywords name="Numbers, prefix1"></Keywords>
<Keywords name="Numbers, prefix2"></Keywords>
@tuhin47
tuhin47 / Dockerfile
Last active April 28, 2021 18:10
Spring boot + MySQL docker
FROM adoptopenjdk/openjdk11:alpine-jre
# Refer to Maven build -> finalName
ARG JAR_FILE=target/HibernateSpringBootCalculatePropertyPostLoad-1.0.jar
# cd /opt/app
WORKDIR /opt/app
# cp target/spring-boot-web.jar /opt/app/app.jar
COPY ${JAR_FILE} app.jar
@tuhin47
tuhin47 / Database_Docker_IN_Terminal.md
Last active April 28, 2021 18:35
Mysql Docker Run and Open By terminal

MySQL

Run MySQL docker Command:

docker run --name mysql47 -e MYSQL_ROOT_PASSWORD=root -p 3333:3306 -d mysql

Connect from terminal:

mysql -h 127.0.0.1 -P 3333 -u root -p
@tuhin47
tuhin47 / Java Json Deserializer.md
Created April 29, 2021 03:32
Java Json Deserializer

Java Code

public class InstantTimeDeserializer extends JsonDeserializer<Instant> {
    @Override
    public Instant deserialize(JsonParser arg0, DeserializationContext arg1) throws IOException {
        return Instant.parse(arg0.getText());
    }
}
@tuhin47
tuhin47 / Spring Date And User Audit.md
Created April 29, 2021 17:00
Spring Date And User Audit

Spring Date And User Audit

DateAudit.java

@MappedSuperclass
@Data
@EntityListeners(AuditingEntityListener.class)
@JsonIgnoreProperties(
		value = { "createdAt", "updatedAt" },
@tuhin47
tuhin47 / Spring Current User.md
Created April 29, 2021 17:02
Spring Current User

CurrentUser.java

@Target({ElementType.PARAMETER, ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Documented
@AuthenticationPrincipal
public @interface CurrentUser {
}
@tuhin47
tuhin47 / Spring boot Server Side Pagination.md
Created May 3, 2021 17:09
Spring boot Server Side Pagination Using JPA

GenericSpecification.java

public class GenericSpecification<T> implements Specification<T> {
    private static final long serialVersionUID = 1900581010229669687L;

    private List<SearchCriteria> list;

    public GenericSpecification() {

Find String inside file

grep -rl 'string' **/** | xargs sed -i 's/srtring/replace/g'
@tuhin47
tuhin47 / Java Json Serialize and Deserialize Converter.md
Created June 3, 2021 05:56
Java Json Serialize/deserialize Converter

Serialize

@JsonSerialize

@JsonSerialize(converter = DoubleAmountConverter.class)
private Double grandTotal;

DoubleAmountConverter.java

@tuhin47
tuhin47 / Upgrade Java Version.md
Created March 6, 2022 04:05
Upgrade Java from 8 to 11 or higher

Error thrown as :

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaAutoConfiguration.class]: Invocation of init method failed; nested exception is javax.persistence.PersistenceException: [PersistenceUnit: default] Unable to build Hibernate SessionFactory

Solution

<!-- https://mvnrepository.com/artifact/javax.xml.bind/jaxb-api -->