2017년 6월 28일 수요일

Spring Boot web app을 war로 배포 및 devtools

소스:

https://github.com/julyinsung/springboot/tree/master/boot_mvc_war_deploy

환경:

Type: gradle, Packaging: Jar, Java Version: 1.8
Boot Version: 1.5.4
Dependencies: Web, Thymeleaf
Tomcat: 1.8

개요:

Spring Boot을 이용하여 Web 프로젝트를 만들고 이를 war파일로 만들어서 Tomcat에 배포
devtools를 이용하여 java파일 수정시 자동으로 서버 재시작

프로젝트 구성은 아래와 같다.


프로젝트 생성후 메인 클래스에 아래와 같이 configure() 메소드를 추가한다.
@SpringBootApplication
public class BootMvcWarDeployApplication extends SpringBootServletInitializer {


 @Override
 protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
  return application.sources(BootMvcWarDeployApplication.class);
 }


 public static void main(String[] args) {
  SpringApplication.run(BootMvcWarDeployApplication.class, args);
 }
}
build.gradle파일에 아래 코드를 추가한다.
dependencies compile('org.springframework.boot:spring-boot-devtools')을 추가한다.
apply plugin: 'war'

war {
    baseName = 'ROOT'
    //version = '0.0.1-SNAPSHOT'
}

dependencies {
 compile('org.springframework.boot:spring-boot-starter-thymeleaf')
 compile('org.springframework.boot:spring-boot-starter-web')
 compile('org.springframework.boot:spring-boot-devtools')
 testCompile('org.springframework.boot:spring-boot-starter-test')
}
[프로젝트 명 마우스 오른 클릭 > Gradle > Refresh Gradle Project ]를 하면 Gradle Tasks 의 build Task에 war 이 생성된다. war를 클릭하면 파일이 생성되며 생성된 파일은 [프로젝트폴더 > build > lib] 에 위치한다.


ROOT.war로 생성된 파일을 Tomcat에 넣고 실행하면 결과를 볼 수 있다.
Tomcat에 배포하지 않고 IDE상에서 확인하기 위해서는 [Run As > Spring Boot App] 을 실행한다.

2017년 6월 22일 목요일

ObjectAid UML - 클래스다이어그램 Eclipse Plugin

Eclipse에서 코드를 Class Diagram으로 변환해 주는 Plugin.
작성한 클래스들의 구조를 볼때 유용하게 사용할 수 있다.

참조

설치: http://www.objectaid.com/installation


설치가 완료되면 그림과 같이 New > Other... > Objectaid UML Diagram > Class Diagram을 선택한다.

Next를 선택하여 그림과 같이 이름을 넣고 Finish버튼을 클릭하면 파일이 생성된다.

생성된 파일을 선택하면 빈 화면이 나타나게 되는데 빈 화면에 클래스를 끌어다 놓으면 Class Diagram을 생성해 준다.  생성된 Class Diagram은 이미지로 저장할 수 있다.



2017년 6월 15일 목요일

Vertx 연습 - web

소스: 

https://github.com/julyinsung/vertx_sample/tree/master/vertx-web

참고:

vertx-web: http://vertx.io/docs/vertx-web/java/
rest example: https://github.com/vert-x3/vertx-examples/blob/master/web-examples/src/main/java/io/vertx/example/web/rest/SimpleREST.java

환경:

vertx 3.x, java1.8, Eclipse

개요:

vertx의 web 라이브러리를 이용하여 간단한 rest api서버를 만들고 mongodb에 조회및 insert 기능.
rest 구현 클래스와 mongodb 클래스는 eventbus를 이용한다.

설명:

vertx web을 사용하기 위해서는 pom.xml에 dependency를 추가한다.

vertx web에서 HTTP request를 해당 URL로 매칭하기 위해서 Router를 사용한다.

보내는 쪽은 send를 받는 쪽은 consumer메소드를 사용한다.
당연히 address는 같아야 한다.
vertx.eventBus().send(address, message, handler)
vertx.eventBus().consumer(address, handler)

2017년 6월 12일 월요일

Bracketeer: the ultimate bracket plugin

Eclipse Editor 창에서 bracket을 강조해주는 plug-in.

참조: https://mcuoneclipse.com/2012/06/10/bracketeer-the-ultimate-bracket-plugin/

Marketplace에서 Bracketeer로 검색하여 설치가능.


Indent Guide (vertical line on indentation columns)

Eclipse Editor 창에서 들여쓰기 세로라인을 생성해주는 plug-in.

참조https://sschaef.github.io/IndentGuide/

update site를 이용하여 설치한다.
http://sschaef.github.io/IndentGuide/update/







30년간 개발자로 살면서 배운것

출처: 

https://taegon.kim/archives/6546

내용 요약:


  • 고객은 결과물을 본 후에야 자신이 뭘 원했는지 안다.
  • 시간이 충분하다면 보안은 반드시 실패한다.
  • 보안은 반드시 실패하지만, 결과는 그 상황에 대해 미리 계획을 세워두었는지에 따라 달라진다.
  • 좋은 보안은 지출이 아닌 전략 자원이다. 나쁜 보안은 비싼 대가를 치른다.
  • 복잡한 걸 간단해 보이게 만드는 건 어렵지만 복잡한 걸 더 복잡해 보이게 만드는 건 쉽다.
  • 성공은 실수를 통해 배운 것에서 비롯된다. 실패는 실수가 정상적이며 그 정도는 용인할 수 있다고 착각하는 데서 비롯된다.
  • 유일하게 변하지 않는 건 변화 그 자체이며, 우리는 변화를 거부할 수 없다.
  • 끊임없이 학습하라. 기술이라는 스팀 롤러는 바로 뒤에 붙어서 당신이 멈출 때만 기다리고 있다.
  • 소프트웨어 산업은 어림짐작을 기반으로 한다.
  • 당신에게 좋았다고 다른 사람에게도 좋을 거란 보장은 없다.
  • 끊임없이 변하는 세상에서 가장 중요한 기술은 안목이다.
  • 목적을 달성하는 방법엔 여러 가지가 있지만, 고객 입장에선 뭐든 상관없다.
  • 품질은 고객이 제일 잘 평가한다.
  • 로그를 남기지 않아 몰랐던 것이 큰 문제가 될 수 있다.
  • 언제나 더 나은 길은 있을 테지만 시간은 기다려주지 않는다.


Vert.x 글모음

Vert.x 공식 사이트
http://vertx.io/docs/

비동기 네트워크 서버 프레임웍 Vert.x 소개 (조대협)
http://bcho.tistory.com/860

입문: http://blog.funhnc.com/entry/Vertx-%EA%B0%80-%EC%A2%8B%EB%8B%A4-%EC%A0%9C-1%ED%9A%8C-%EC%9E%85%EB%AC%B8

개발환경구축http://blog.funhnc.com/entry/Vertx%EA%B0%80-%EC%A2%8B%EB%8B%A4-%EC%A0%9C-2%ED%9A%8C-%EA%B0%9C%EB%B0%9C-%ED%99%98%EA%B2%BD-%EA%B5%AC%EC%B6%95

event loops와 verticle instances: http://blog.funhnc.com/entry/Vertx-%EA%B0%80-%EC%A2%8B%EB%8B%A4-%EC%A0%9C-3%ED%9A%8C-Event-Loops%EC%99%80-Verticle-Instances

Vert.x 3 의 아버지 Tim Fox 와의 인터뷰: http://hamait.tistory.com/704

노만 머러 인터뷰 (Netty/Vert.x): http://hamait.tistory.com/377

vert.x는 무엇이 좋은가?: http://d2.naver.com/helloworld/163784

vertx 사용예 (Zookeeper와 vertx를 활용한 실시간 push 서비스 개발기)
http://lyb1495.tistory.com/105

Vert.x 3.0 cluster 구축하기
http://yakolla.tistory.com/95


Vertx 연습 - mongodb client

소스:

https://github.com/julyinsung/vertx_sample/tree/master/vertx-mongodb

참고:

vertx page: http://vertx.io/docs/
vertx mongodb client: http://vertx.io/docs/vertx-mongo-client/java/
vertx blog first application: http://vertx.io/blog/my-first-vert-x-3-application/

환경:

vertx 3.x, java1.8, Eclipse

개요:

vertx의 개발환경을 위한 셋팅
mongodb를 이용한 연습프로그래밍(mongodb에 관한 사항은 제외)

설명:

vertx에 대한 설명은 구글에서 검색하면 다양한 정보를 얻을 수 있다.
vertx는 JVM 위에서 작동하는 비동기 프로그래밍을 위한 프레임워크이다.

1. 프로젝트 생성

eclipse에서 maven 프로젝트를 만든다.

2. 빌드및 실행

빌드하여 jar파일을 만든다. 이때 실행가능한 jar파일을 만들 수 있는데 pom.xml에서와 같이 maven-shade-plugin을 사용한다.


 
  org.apache.maven.plugins
  maven-shade-plugin
  2.3
  
   
    package
    
     shade
    
    
     
      
       
        io.vertx.core.Launcher
        vertx.mongo.sample.MongodbpersisterVerticle
       
      
     
     
     ${project.build.directory}/${project.artifactId}-${project.version}-fat.jar
    
   
  
 

2.1. eclipse를 이용한 빌드

그림과 같이 eclipse의 run configuration를 설정한다.(Maven Build type)

설정 후 build를 하면 target폴더에 xxx.jar와 xxx-fat.jar이 생성되고 cmd창에서 java -jar xxx-fat.jar 명령으로 실행한다.

2.2. eclipse를 이용한 실행

그림과 같이 eclipse의 run configuration를 설정한다. (Java Application type)
Main 탭

Arguments 탭

Main탭의 main Class는 io.vertx.core.Launcher
Arguments 탭의 Arguments에는 pom.xml에 보듯이 Main-Class와 Main-Verticle을 적고 실행시킬 jar파일을 적고 실행을 한다.
이때 먼저 1번을 통해서 jar파일이 만들어져 있어야 한다.
run vertx.mongo.sample.MongodbpersisterVerticle -cp target/vertx-mongodb-0.0.1-SNAPSHOT.jar

결론적으로 프로젝트를 실행시키기 위해서는
1번과 같이 xxx-fat.jar를 만들어서 cmd로 직접 jar파일을 실행하는 방법과
1번 실행후 2번을 실행하여 Eclipse상에서 실행을 할 수 있다. 

[참고] run configuration을 좀더 편하게 사용하기 위해서는 Run Configuration Latest View 플러그인을 사용하면 된다.

2017년 6월 11일 일요일

Launch Configurations View

Eclipse의 Run Configuration  사용성을 개선한 plug-in.

참조https://marketplace.eclipse.org/content/launch-configuration-view

그림과 같이 Eclipse의 툴바에 있는 것을 창으로 만들어서 관리 및 사용이 용이하다.
Eclipse Marketplace에서 Launch Configuration View Latest를 검색하여 설치 가능.

Toolbar의 Run 메뉴
Plug-in 설치 화면