libraryDependencies ++= Seq( "org.mybatis" % "mybatis" % "3.1.1", "mysql" % "mysql-connector-java" % "5.1.26", "net.sf.flexjson" % "flexjson" % "3.1", javaCore, javaJdbc, cache )저장하고 프로젝트의 디펜던시를 업데이트한다.
~/Project/workspace/dottegi/dottegi_server> play debug Listening for transport dt_socket at address: 9999 [info] Loading project definition from /Users/yangsaerohoon/Project/workspace/dottegi/dottegi_server/project [info] Set current project to dottegi_server (in build file:/Users/yangsaerohoon/Project/workspace/dottegi/dottegi_server/) _ _ __ | | __ _ _ _ | '_ \| |/ _' | || | | __/|_|\____|\__ / |_| |__/ play 2.2.0 built with Scala 2.10.2 (running Java 1.7.0_25), http://www.playframework.com > Type "help play" or "license" for more information. > Type "exit" or use Ctrl+D to leave this console. [dottegi_server] $ update [info] Updating {file:/Users/yangsaerohoon/Project/workspace/dottegi/dottegi_server/}dottegi_server... [info] Resolving org.fusesource.jansi#jansi;1.4 ... [info] downloading http://repo1.maven.org/maven2/net/sf/flexjson/flexjson/3.1/flexjson-3.1.jar ... [info] [SUCCESSFUL ] net.sf.flexjson#flexjson;3.1!flexjson.jar (1109ms) [info] Done updating. [success] Total time: 12 s, completed Oct 25, 2013 11:36:18 AM [dottegi_server] $ eclipse [info] About to create Eclipse project files for your project(s). [info] Successfully created Eclipse project files for project(s): [info] dottegi_server어제 만지던 테스트용 컨트롤러를 조금 수정해서 제대로 json 결과를 리턴하는지 테스트. 브라우저로 하는 것 보다는 restclient를 이용하는 것이 낫겠다.
public static Result getUser(String id) { SqlSession sqlSession = MyBatisFactory.getDefaultClient(); User user = sqlSession.selectOne("sample.searchUser", Integer.valueOf(id)); JSONSerializer serializer = new JSONSerializer(); String jsonResult = serializer.prettyPrint(true).serialize(user); System.out.println(jsonResult); return ok(jsonResult); }이렇게 수정하고 실행.
[dottegi_server] $ run --- (Running the application from SBT, auto-reloading is enabled) --- [info] play - Listening for HTTP on /0:0:0:0:0:0:0:0:9000 (Server started, use Ctrl+D to stop and go back to the console...)restclient를 돌려 보면
잘 나온다. 오케이.
댓글 없음:
댓글 쓰기