-
Notifications
You must be signed in to change notification settings - Fork 10
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
[21기_이석원] spring tutorial 미션 제출합니다. #9
base: leerura
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,75 @@ | ||
# spring-tutorial-21st | ||
CEOS back-end 21st spring tutorial project | ||
Spring Tutorial 21st | ||
|
||
CEOS Back-end 21st Spring Tutorial Project | ||
|
||
시작하기 앞서... | ||
|
||
Spring도 Java도 처음 접하는 입장에서 시행착오를 겪으며 배운 내용을 정리했습니다. | ||
별의별 걸 다 적었다고 느끼실 수도 있지만... 자라나는 새싹을 본다는 마음으로 봐주세용. | ||
|
||
1. 서버(애플리케이션) 실행 | ||
|
||
./gradlew bootRun | ||
|
||
bootRun 실행 시 SpringApplication.run()을 호출하여 @SpringBootApplication이 붙은 main 클래스를 실행합니다. | ||
|
||
|
||
2. 서버 실행 확인 | ||
|
||
브라우저나 curl을 통해 확인 가능 | ||
|
||
3. 의존성 추가 및 확인 | ||
|
||
./gradlew dependencies | ||
|
||
dependencies 수정했다면 꼭 ./gradlew build --refresh-dependencies 하기 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 인텔리제이 쓰시나요? 그러면 아마 gradle을 수정할 때마다 코끼리 모양이 둥둥 떠다닐겁니다! 그거 누르셔도 돼요:) |
||
|
||
이거 안 해서 Can't resolve 에러 많이 만났습니다... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 많이 만났습니다 ㅎㅎ... |
||
|
||
4. 어노테이션이란? | ||
|
||
어노테이션(Annotation)은 Java 코드에 추가적인 정보를 제공하는 특수한 기호입니다. @로 시작하며, 코드의 의미를 설명하고 특정 기능을 자동으로 수행할 수 있도록 도와줍니다. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 사용자 정의 어노테이션을 통해서 원하는 기능을 수행하는 어노테이션을 만들 수 있습니다! 사용자 정의 어노테이션 공부를 통해서 다른 어노테이션 구현체를 확인할 때 도움이 되실 거 같아요! https://ittrue.tistory.com/158 개발을 할때 어노테이션을 정말 많이 사용하기 때문에 구현체를 봐가면서 공부하는게 전 도움이 되더라고요! |
||
|
||
예제: | ||
|
||
@RestController // REST API를 처리하는 컨트롤러 선언 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @RestController와 비슷하게 @controller도 있는 것으로 아는데, 이 둘의 차이점과 어떤 걸 주로 쓰는지 알아보면 이후 프로젝트에 적용할 수 있을 것 같습니다!
|
||
@GetMapping("/") // HTTP GET 요청을 특정 메서드에 매핑 | ||
|
||
5. 몰랐던 개념 정리 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 이렇게 개념 정리하고 가는거 너무 좋아요~~ |
||
|
||
인터페이스 : 클래스가 구현해야 할 메서드의 틀을 정의하는 것 (규칙 정하기) | ||
|
||
빈(Bean) : Spring이 관리하는 객체 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bean의 라이프 사이클에 대해 알아보셔도 이해에 도움이 될 것 같습니다! |
||
Spring 컨테이너 : 빈들을 생성하고 의존성을 자동으로 주입하는 공간 | ||
|
||
static : 변수나 메서드가 클래스 자체에 속하며, 객체를 생성하지 않고도 사용 가능 | ||
|
||
//빈이랑 컨테이너에 대해 더 찾아봤는데 생성, 소멸... 등등 잘 와닿지 않는 내용이 많았습니다. | ||
추가적으로 더 공부해보아야 할 것 같습니다. | ||
|
||
6. 단위 테스트(Unit Test) | ||
|
||
**단위 테스트(Unit Test)**는 코드의 가장 작은 단위(메서드, 클래스)를 독립적으로 테스트하는 것을 의미합니다. | ||
|
||
7. 데이터베이스 | ||
|
||
Spring Boot 데이터 계층 구성 | ||
|
||
Domain : 모델 (Entity) | ||
|
||
Repository : 데이터 저장소 (JPA, MyBatis 등) DB에서 데이터 가져옴 | ||
|
||
Service : 로직 처리 , 실제 로직 처리 | ||
|
||
Comment on lines
+57
to
+64
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 여기서 DTO에 관련된 내용도 추가적으로 찾아보시면 좋을 거 같아요!~! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. DTO를 찾아보면서 DAO와 차이점도 알아두면 좋을 것 같아요. 이름이 비슷해서 저도 늘 헷갈려요.. |
||
Controller : REST API 제공 => 요청 받고 응답 반환 | ||
|
||
//Service와 Controller의 차이 => 데이터베이스 할 때 둘이 비슷하게 생겨서 뭔 차인지 싶어서 찾아보았습니다. | ||
Service가 로직을 처리하는 핵심, Controller는 요청받고 그 요청을 Service에게 전달하고 응답을 보내는 역할이라고 하더군요. | ||
Comment on lines
+67
to
+68
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저는 처음 이해할 때 service는 장고의 view와 유사하고 controller는 url라고 이해를 했던 거 같아요! 자세하게 들어가면 차이점도 있으니 조금 더 알아보시면 더 쉽게 이해하실 수 있을 거 같아요! 추가적으로 웹 어플리케이션의 다양한 디자인 패턴에 대해서도 공부하면 도움이 될 것 같습니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Service와 Controller가 구분되는 이유를 알기 위해서 MVC 패턴을 찾아보면 어떨까 생각이 듭니다! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
TMI: | ||
|
||
마지막에 테이블 생성이 안 돼서 고생함. 알고 보니 Test 엔티티와 관련된 클래스들이 Application과 같은 패키지에 있어야 했음. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저는 처음에 H2에 TEST가 안 생기더라고요... |
||
|
||
느낀 점: Java 같은 객체지향언어가 처음인데 진짜 다 클래스로 나타내더라고요. | ||
신기했습니다. 아직 Java를 잘 몰라서 모든 코드를 완전 이해한 것은 아니지만 지금부터 차근차근 더 노력해보겠습니다. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도 잘 모르는데 같이 노력해봐요.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 저도요.. 저희 함께 화이팅입니다 👍 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/gradlew text eol=lf | ||
*.bat text eol=crlf | ||
*.jar binary |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
HELP.md | ||
.gradle | ||
build/ | ||
!gradle/wrapper/gradle-wrapper.jar | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### STS ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
bin/ | ||
!**/src/main/**/bin/ | ||
!**/src/test/**/bin/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea | ||
*.iws | ||
*.iml | ||
*.ipr | ||
out/ | ||
!**/src/main/**/out/ | ||
!**/src/test/**/out/ | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
|
||
### VS Code ### | ||
.vscode/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
|
||
Controller 작성 | ||
어노테이션이란?? | ||
=> Java 코드에 추가적인 정보를 제공하는 특수한 기호, @로 시작함, | ||
코드의 의미를 설명하고 자동으로 동작할 수 있도록 설명 | ||
ex> @RestController, @GetMapping ... | ||
|
||
Application class 수정 | ||
|
||
인터페이스 => 인터페이스는 클래스가 구현해야 할 메서드의 틀을 정의하는 것.(규칙 정하기) | ||
빈(Bean) => Spring이 관리하는 객체 | ||
Spring 컨테이너 => 빈들을 관리하는 공간, 빈들을 생성하고 의존성을 자동으로 주입 | ||
static => 변수나 메서드가 클래스 자체에 속하며, 객체를 생성하지 않고도 사용 가능 | ||
args => arguments | ||
|
||
@SpringBootApplication = @Configuration(Spring 설정 파일) + @EnableAutoConfiguration(필요한 빈들을 자동 등록) + @ComponentScan(현재 패키지에서 Spring 빈을 찾아 등록) | ||
|
||
단위 테스트 | ||
|
||
단위 테스트란 => 코드의 가장 작은 단위(메서드, 클래스)를 독립적으로 테스트하는 것 | ||
|
||
데이터베이스 | ||
|
||
TCP란? Transmission Control Protocal | ||
|
||
Domain : 모델 | ||
Repository : 저장소 | ||
Service : 로직 처리 | ||
Controller : Rest API |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
plugins { | ||
id 'java' | ||
id 'org.springframework.boot' version '3.4.3' | ||
id 'io.spring.dependency-management' version '1.1.7' | ||
} | ||
|
||
group = 'com.ceos21' | ||
version = '0.0.1-SNAPSHOT' | ||
|
||
java { | ||
toolchain { | ||
languageVersion = JavaLanguageVersion.of(21) | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation 'org.springframework.boot:spring-boot-starter-web' | ||
testImplementation 'org.springframework.boot:spring-boot-starter-test' | ||
|
||
implementation 'org.springframework.boot:spring-boot-starter-data-jpa' | ||
compileOnly 'org.projectlombok:lombok' | ||
annotationProcessor 'org.projectlombok:lombok' | ||
runtimeOnly 'com.h2database:h2' | ||
|
||
//testImplementation 'org.springframework:spring-test' | ||
|
||
|
||
//testRuntimeOnly 'org.junit.platform:junit-platform-launcher' | ||
|
||
} | ||
|
||
tasks.named('test') { | ||
useJUnitPlatform() | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.13-bin.zip | ||
networkTimeout=10000 | ||
validateDistributionUrl=true | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아자아자 화이팅~!