티스토리 뷰

기타

maven multi 모듈

SonSeungWoo 2019. 1. 26. 00:18

maven multi 모듈

몇 년? 만에 블로그를 다시 작성한다. 목적은 개인 공부 및 기록? 예습, 복습 차원에서 작성한다. 그래서 설명이 부족할 수 있다. 꾸준히
작성하자.
다시 시작은 maven multi 모듈 프로젝트 구조를 만들어 보자. 멀티 모듈로 구성해야 할 일이 있어 예전에 했었지만 기억이 안 나서 다시
한번 정리 하려고 한다. 필자는 IDE intellij를 사용하여 intellij 기반으로 설명하도록 하겠다.
먼저 상단메뉴 file-> new -> Project 클릭하여 프로젝트를 생성하자. 그리고 왼쪽 메뉴에서 maven을 선택하자. 
그리고 next -> GroupId, ArtifactId 입력하고 next -> finish



다음 이제 parent 프로젝트 하위에 모듈을 만들어 보자 parent프로젝트를 선택하고 프로젝트를 생성하자. 역시 maven을 선택해서 생성하자.



ArtifactId를 입력하고 next



parent모듈 pom.xml을 보면 방금 추가한 모듈이 자동으로 추가되어 있다.


같은 방식으로 springWeb이라는 모듈을 하나 생성하겠다. springWeb에서 springboot 테스트를 해보겠다.

spring-boot로 진행하기 위해 아래와 같이 parent모듈에 parent를 추가해주자.

<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.1.RELEASE</version>
<relativePath/>
</parent>

부모 모듈에 공통으로 사용될 디펜더시를 추가해주면 하위 모듈들은 공통으로 사용할 수있다.

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
</dependency>
</dependencies>

spring-boot-test를 추가해주자.


core모듈에는 데이터베이스와 관련된 디펜던시를 추가해주자. 필자는 마이바티스 기반으로 하겠다. 추후 마이마티스관련 글을 작성할것이기

때문이다. lombok도 추가해주자.

<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
</dependency>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</dependency>

springWeb모듈에는 web을 추가하자. core도 디펜던시 받자.

<dependencies>
<dependency>
<groupId>me.seungwoo</groupId>
<artifactId>core</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

core모듈에는 service 및 mapper를 springWeb에는 controller를 작성할 것이다.

간단한 예제는 github에 있다.

'기타' 카테고리의 다른 글

Apache Kafka  (0) 2019.06.28
Mybatis oracle procedure xmlType 처리  (0) 2019.02.15
Agile Practices - Scrum/Kanban  (0) 2018.04.23
TDD, BDD  (0) 2018.04.23
클라우드 서비스 유형(IaaS, PaaS, SaaS)  (0) 2018.04.23
공지사항
최근에 올라온 글
최근에 달린 댓글
링크
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31
글 보관함