전체 글
-
git - commit한 것 되돌리기Git 2022. 5. 31. 18:58
브랜치 관리를 하다보면 이미 remote branch에 커밋한 내용을 원복하고 싶은 경우가 있습니다. 이럴때 사용할 수 있는 git revert 명령어에 대해서 알아보겠습니다. first라는 commit을 했는데 이것을 원복하고 싶은 경우입니다. test@iMac demo % git log --oneline 1dc73d5 (HEAD -> master, origin/master) first 4ac8c30 init 마지막 커밋 1dc73d5에 대해 패치 파일을 생성합니다. test@iMac demo % git format-patch -1 1dc73d5 0001-first.patch git apply 명령어를 통해서 패치 파일을 commit합니다. (commit 내용은 1dc73d5 내용 원복) git sta..
-
JSON 이스케이프 처리tools 2022. 5. 31. 18:48
JSON 이스케이프 문자 변환해주는 사이트 https://www.freeformatter.com/json-escape.html#ad-output Free Online JSON Escape / Unescape Tool - FreeFormatter.com JSON String Escape / Unescape Escapes or unescapes a JSON string removing traces of offending characters that could prevent parsing. The following characters are reserved in JSON and must be properly escaped to be used in strings: Backspace is replaced wit ..
-
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: Error attempting to apply AttributeConverter; nested exception is javax.persistence.PersistenceExceptionSpring 2022. 5. 31. 18:45
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: Error attempting to apply AttributeConverter; nested exception is javax.persistence.PersistenceException:.. JPA AttributeConverter에서 exception 발생하는 경우입니다. JPA entity에서 conveter를 만들어서 사용하는 경우에 null 처리가 안되어 있을 때 발생합니다. public class ExampleEntity { // ...
-
Java - 싱글턴(Singleton) 패턴Java 2022. 5. 30. 20:26
싱글턴 패턴이란? 애플리케이션이 시작될 때 어떤 클래스가 최초 한번만 메모리를 할당하고(static) 그 메모리에 인스턴스를 만들어 사용하는 디자인 패턴 생성자가 여러 차례 호출되더라도 실제로 생성되는 객체는 하나고 최초 생성 이후에 호출된 생성자는 최초에 생성한 객체를 반환 다른 클래스 인스턴스들과 데이터 공유가 쉬움 Database Connection Pool처럼 공통된 객체를 여러개 생성해서 사용해야하는 상황에서 많이 사용(쓰레드풀, 캐시, 로그 기록 객체등) anti-pattern이므로 가급적 사용하지 않는 것이 좋음 싱글턴 패턴의 문제점 너무 많은 일을 하거나 많은 데이터를 공유시킬 경우 다른 클래스 인스턴스들 간의 결합도가 높아져 "개방-폐쇄 원칙"을 위배하게 된다. 수정, 테스트가 어려움 싱..
-
Java - 자바 절대값, 랜덤 함수Java 2022. 5. 30. 19:42
안녕하세요. 오늘은 자바의 Math 클래스를 이용하여 절대값과 랜덤값 생성하는 방법을 알아보겠습니다. java.lang.Math 클래스는 수학에서 자주 쓰이는 함수들을 구현해 놓은 클래스입니다. 절대값(abs) 구하기 Math.abs()를 이용해서 절대값을 구할 수 있습니다. import java.lang.Math; class HelloWorld { public static void main(String[] args) { System.out.println(Math.abs(10)); // 10 System.out.println(Math.abs(-10)); // 10 System.out.println(Math.abs(-1.2); // 1.2 } } 랜덤값 구하기 Math.random()을 이용해서 랜덤값을 ..