본문 바로가기

Programming

spring restful service - JSON response In Spring, we could get following error message from REST client or other HttpClient modules, when we have not implemented fields getter / setter methods in class that represents JSON response object. The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers (). 더보기
IntelliJ GenerateSerialVersionUID In IntelliJ, compared with Eclipse, you should install GenerateSerialVersionUID manually, if you want get serialVersionUID field automatically. (IntelliJ 에는 Serializable interface 를 implements 할 경우, serialVersionUID 를 자동으로 생성해 주는 plugin 을 설치해야 한다.) Install plugins like below (아래와 같은 방식으로 설치를 하면 된다.)Preference -> Plugins -> Browse repositories -> GenerateSerialVersionUID 더보기
maven - set properties file content from command line 1. enable filtering of resources like below (아래와 같이 resource filtering 을 활성화 시킨다) src/main/resources true 2. then, declare a place holder in your src/main/resources/my.properties, like below.(properties 파일에 대입할 변수를 아래와 같이, 선언한다 => ${db.server.ip}) prop1 = blah prop2 = ${db.server.ip} 3. declare properties and it's value in a profile.(maven 의 설정파일인 pom.xml 에 아래와 같이 properties 파일에 대한 변수와 값을 설정한다.).. 더보기
ExceptionUtils - java 에서 exception 관련 처리를 쉽게 도와주는 클래스 Exception 관련 처리를 임의로 가공하여 처리하고 싶을때 편의를 제공해 주는 apache commons-lang package 에 있는 library 이다. http://commons.apache.org/proper/commons-lang/ 사용예: String message = null; try { String str = null str.toUpperCase(); } catch (Exception e) { message = ExceptionUtils.getFullStackTrace(e); } System.out.println(message); 이보다 다양한 기능을 제공하고 있으니 documentation 을 참고하자. javadoc api: http://commons.apache.org/prope.. 더보기
쉽게 따라하는 자바 웹개발 legacy-sample 공부한 코드들 쉽게 따라하는 자바 웹 개발이라는 책이 있다. 인사이트에서 출간하였고, NHN 비즈니스 플랫폼에서 일하고 있는 백기선 이라는 분이 저자이다. 최근에 이 책을 보고 공부를 하고 있는데, 필요한 핵심만 정확하게 그리고 친절하게 안내가 되어 있어서 좋은 인상을 주었다. 이 책에서는 legacy-sample 이라는 프로젝트로 eclipse, maven, spring, ibatis, hibernate 를 소개한다. 이 책을 읽어보고 토비의 spring 이라는 책도 읽어보면 좋을 거 같다는 생각이 들었다. 여기서 진행하는 project 인 legacy-sample 이라는 소스코드는 개인적으로 공부를 하면서 update 한 코드들은 github 에 올렸다. 주소는 아래와 같다. https://github.com/st.. 더보기
Coursera Functional Programming Principles in Scala certificate 없는 시간 쪼개어 가며 공부했던 성과를 얻었다.뿌듯하다. 내 자신이 자랑스럽다고 느껴진다. ^^ 다른 분들도 저와 같은 즐거움을 느껴 보시길~ 더보기
Scala Style Guide Scala 로 코딩하는 이들을 위해서 스타일 가이드를 남겨둔다.참고: https://class.coursera.org/progfun-002/wiki/view?page=ScalaStyleGuide (이 링크는 없어질 수도 있다.) Scala Style GuideOn this page you can find a list of common issues that we detected while looking at some submissions.Some of the style issues can be detected by the automated style checker that we also use for the grading process. The style checker, which is based on S.. 더보기
function's placeholder annotation Scala 에서 아래와 같이 코드를 작성할 수 있다. val list = List("abc", "def", "ddddd") list.map(str => Vector(str: _*)) 결과가 어떻게 될까? 재미있게도 아래와 같이 나온다.List[scala.collection.immutable.Vector[Char]] = List(Vector(a, b, c), Vector(d, e, f), Vector(d, d, d, d, d)) 여기서 str: _* 은 무슨 일을 하는 녀석일까?이 녀석은 str 안에 있는 Char 들의 갯수만큼 Vector 에 인자들을 추가하라는 이야기 이다.코드는 엄청 간결하지만, 많은 일을 하고 있다.하지만 문법이 조금 난해하다. 더보기
Java 프로그램에서 garbage collection 이 얼마나 일어나는 지 알아 내기 Java 프로그램이 커지면 커질 수록 garbage collection 은 큰 관심의 대상이 된다. 자신이 작성한, 혹은 작성된 어떤 프로그램의 garbage collection 이 어떻게 되는 지 알고 싶다면,JVM 옵션으로 아래 값을 설정해 주면 프로그램이 실행 되는 도중에 JVM 이 garbage collection 의 현황을 보고 한다. org.apache.tools.ant $ java -verbose:gc 더보기
Java 에서 자원 할당하고 해제하기 (괜찮은 패턴) Java 에서 자원을 할당하고 해제하는 코드는 상당히 귀찮고 코드도 복잡하게 될 수 있다. 보통 아래와 같이 코드를 작성한다. public void test(String inputFileName, String outputFileName) { InputStream in = null; OutputStream out = null; try { in = new FileInputStream(inputFileName); out = new FileOutputStream(outputFileName); copy(in, out); } catch (FileNotFoundException e) { e.printStackTrace(); } finally { if (in != null) { try { in.close(); } ca.. 더보기