Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[#6] 싱글모듈>멀티모듈 #7

Merged
merged 6 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# cosmetics-delivery
선착순 타임딜 톡톡 라인업, 화장품 구매 배달 서비스

## 멀티 모듈 프로젝트 구성
- module-core
- module-api
44 changes: 27 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,40 @@ plugins {
id 'io.spring.dependency-management' version '1.1.4'
}

group = 'com.hello'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '21'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
allprojects {
group = 'com.hello'
version = '0.0.1-SNAPSHOT'

repositories {
mavenCentral()
}
}

repositories {
mavenCentral()
}
subprojects {
apply plugin: 'java'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}

tasks.named('test') {
useJUnitPlatform()
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
implementation 'com.googlecode.json-simple:json-simple:1.1.1'

}

tasks.named('test') {
useJUnitPlatform()
}
}
11 changes: 11 additions & 0 deletions module-api/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
plugins {
}

dependencies {
implementation project(path: ':module-core')
}

//어플리케이션 실행에 필요한 모든 의존성을 포함하지 않고 클래스파일과 리소스 파일만 포함
//web 모듈을 추가하면서 bootJar를 사용하지 않는다.
tasks.jar { enabled = true }
tasks.bootJar { enabled = false }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 설정을 넣어야하는거라면, springboot plugin을 빼는게 더 좋지 않을까요?

Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.hello.cosmetics;
package com.cosmetics;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;

@SpringBootApplication
@SpringBootApplication(scanBasePackages = "com.cosmetics")
public class CosmeticsApplication {

public static void main(String[] args) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.cosmetics.sample.controller;

import com.cosmetics.Sample;
import com.cosmetics.sample.service.SampleService;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class SampleController {

@Autowired
private SampleService sampleService;
@GetMapping("/hello")
public Sample getHelloCosmetics() {
Sample say = sampleService.getSample();
return say;
}
@PostMapping("/hello")
public Sample postHelloCosmetics(@RequestBody Sample sampleParam) {
return sampleParam;
}

@GetMapping("/helloObj")
public String getHelloObjectMapper() throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
String str = mapper.writeValueAsString("{\"say\": \"hello\" }");
return str;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.cosmetics.sample.service;

import com.cosmetics.Sample;
import org.springframework.stereotype.Service;

@Service
public class SampleService {

public Sample getSample() {
Sample sample = new Sample();
sample.setSay("hello cosmetics");
return sample;
}
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아무내용도 없으면 지우는 게 더 좋지 않을까 싶습니다.

Empty file.
1 change: 1 addition & 0 deletions module-api/src/main/resources/static/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello Cosmetics!
8 changes: 8 additions & 0 deletions module-core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
plugins {
}

dependencies {
}
//어플리케이션 실행에 필요한 모든 의존성을 포함하지 않고 클래스파일과 리소스 파일만 포함
tasks.jar { enabled = true }
tasks.bootJar { enabled = false }
10 changes: 10 additions & 0 deletions module-core/src/main/java/com/cosmetics/Sample.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.cosmetics;

import lombok.Getter;
import lombok.Setter;

@Getter
@Setter
public class Sample {
private String say;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.cosmetics.example;

import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class ModuleCoreApplicationTest {
@Test
public void sysout(){
System.out.println("core도 테스트가 됩니다.");
}
}
4 changes: 4 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
rootProject.name = 'cosmetics'
include 'module-api'
include 'module-core'
include 'module-web'

13 changes: 0 additions & 13 deletions src/main/java/com/hello/cosmetics/main/MainController.java

This file was deleted.

2 changes: 0 additions & 2 deletions src/main/resources/application.properties

This file was deleted.

1 change: 0 additions & 1 deletion src/main/resources/static/index.html

This file was deleted.

13 changes: 0 additions & 13 deletions src/test/java/com/hello/cosmetics/CosmeticsApplicationTests.java

This file was deleted.

Loading