Java19 Spring - AOP AOP๊ฐ ํ์ํ ์ํฉ ๋ชจ๋ ๋ฉ์๋์ ํธ์ถ ์๊ฐ์ ์ธก์ ํ๊ณ ์ถ๋ค๋ฉด? ๊ณตํต ๊ด์ฌ ์ฌํญ(cross-cutting concern) vs ํต์ฌ ๊ด์ฌ ์ฌํญ(core concern) ํ์ ๊ฐ์ ์๊ฐ, ํ์ ์กฐํ ์๊ฐ์ ์ธก์ ํ๊ณ ์ถ๋ค๋ฉด? MemberService์์ ์ด์๊ฐ์ด ๋ก์งํ๋ํ๋ ์๊ฐ ์ธก์ ์ฝ๋๋ฅผ ์ถ๊ฐํ ์ ์์ง๋ง ๋ก์ง์ด ๋ช๋ฐฑ๊ฐ๊ฐ ๋๋ค๋ฉด.. ๋นํจ์จ์ ์ด๊ณ ์๊ฐ์ด ๋๋ฌด ๋ง์ด ๊ฑธ๋ฆฐ๋ค. ๐ป ๋ฌธ์ ํ์๊ฐ์ , ํ์ ์กฐํ์ ์๊ฐ์ ์ธก์ ํ๋ ๊ธฐ๋ฅ์ ํต์ฌ ๊ด์ฌ ์ฌํญ์ด ์๋๋ค. ์๊ฐ์ ์ธก์ ํ๋ ๋ก์ง์ ๊ณตํต ๊ด์ฌ ์ฌํญ์ด๋ค. ์๊ฐ์ ์ธก์ ํ๋ ๋ก์ง๊ณผ ํต์ฌ ๋น์ฆ๋์ค์ ๋ก์ง์ด ์์ฌ์ ์ ์ง๋ณด์๊ฐ ์ด๋ ต๋ค. ์๊ฐ์ ์ธก์ ํ๋ ๋ก์ง์ ๋ณ๋์ ๊ณตํต ๋ก์ง์ผ๋ก ๋ง๋ค๊ธฐ ๋งค์ฐ ์ด๋ ต๋ค. ์๊ฐ์ ์ธก์ ํ๋ ๋ก์ง์ ๋ณ๊ฒฝํ ๋ ๋ชจ๋ ๋ก์ง์ ์ฐพ์๊ฐ๋ฉด์ ๋ณ๊ฒฝํด์ผ ํ๋ค.. 2023. 7. 5. Spring - DB์ ๊ทผ5 (JPA) JPA๋ ๊ธฐ์กด์ ๋ฐ๋ณต ์ฝ๋๋ ๋ฌผ๋ก ์ด๊ณ , ๊ธฐ๋ณธ์ ์ธ SQL๋ JPA๊ฐ ์ง์ ๋ง๋ค์ด์ ์คํํด์ค๋ค. JPA๋ฅผ ์ฌ์ฉํ๋ฉด, SQL๊ณผ ๋ฐ์ดํฐ ์ค์ฌ์ ์ค๊ณ์์ ๊ฐ์ฒด ์ค์ฌ์ ์ค๊ณ๋ก ํจ๋ฌ๋ค์์ ์ ํ์ ํ ์ ์๋ค. JPA๋ฅผ ์ฌ์ฉํ๋ฉด ๊ฐ๋ฐ ์์ฐ์ฑ์ ํฌ๊ฒ ๋์ผ ์ ์๋ค. JPA๋ ์๋ฐ ์ง์์์ ORM(Object-Relational Mapping) ๊ธฐ์ ํ์ค์ผ๋ก ์ฌ์ฉ๋๋ ์ธํฐํ์ด์ค์ ๋ชจ์์ด๋ค. ๊ทธ ๋ง์ ์ฆ, ์ค์ ์ ์ผ๋ก ๊ตฌํ๋๊ฒ์ด ์๋๋ผ ๊ตฌํ๋ ํด๋์ค์ ๋งคํ์ ํด์ฃผ๊ธฐ ์ํด ์ฌ์ฉ๋๋ ํ๋ ์์ํฌ์ด๋ค. JPA๋ฅผ ๊ตฌํํ ๋ํ์ ์ธ ์คํ์์ค๋ก๋ Hibernate๊ฐ ์๋ค. ORM(Object-Relational Mapping) ์ฐ๋ฆฌ๊ฐ ์ผ๋ฐ ์ ์ผ๋ก ์๊ณ ์๋ ์ ํ๋ฆฌ์ผ์ด์ Class์ RDB(Relational DataBase)์ ํ ์ด๋ธ์ ๋งค.. 2023. 7. 4. Spring - DB์ ๊ทผ4 (JdbcTemplete) ์์ Jdbc์ ๋์ผํ ํ๊ฒฝ์ค์ ์ ํ๋ฉด ๋๋ค. ์คํ๋ง JdbcTemplate๊ณผ MyBatis ๊ฐ์ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ JDBC API์์ ๋ณธ ๋ฐ๋ณต ์ฝ๋๋ฅผ ๋๋ถ๋ถ ์ ๊ฑฐํด์ค๋ค. ํ์ง๋ง SQL์ ์ง์ ์์ฑํด์ผ ํ๋ค. package hello.hellospring.repository; import hello.hellospring.domain.Member; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.jdbc.core.RowMapper; import org.springframework.jdbc.core.namedparam.MapSqlParameterSource; import org.springframework.jdbc.core.. 2023. 7. 4. Spring - DB์ ๊ทผ3 (์คํ๋ง ํตํฉ ํ ์คํธ) ์คํ๋ง - ์คํ๋ง ์ปจํ ์ด๋ - DB ๋ฅผ ํตํฉํ์ฌ ํ ์คํธ package hello.hellospring.service; import hello.hellospring.domain.Member; import hello.hellospring.repository.MemberRepository; import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.transaction.annotation.Transactional; import static .. 2023. 7. 4. Spring - DB์ ๊ทผ2 (๊ณ ์ jdbc ์ด์ฉ) ๊ณ ์ jdbc๋ฅผ ์ด์ฉํด์ ์ ์ฅ์๋ฅผ ์์ฑ package hello.hellospring.repository; import hello.hellospring.domain.Member; import org.springframework.jdbc.datasource.DataSourceUtils; import javax.sql.DataSource; import java.sql.*; import java.util.ArrayList; import java.util.List; import java.util.Optional; public class JdbcMemberRepository implements MemberRepository { private final DataSource dataSource; public Jdbc.. 2023. 7. 4. Spring - ์คํ๋ง๋น๊ณผ์ ์์กด๊ด๊ณ2 ์๋ฐ ์ฝ๋๋ก ์ง์ ์คํ๋ง ๋น ๋ฑ๋กํ๊ธฐ ./hello.hellospring/SpringConfig.java package hello.hellospring; import hello.hellospring.repository.JdbcTemplateMemberRepository; import hello.hellospring.repository.MemberRepository; import hello.hellospring.repository.MemoryMemberRepository; import hello.hellospring.service.MemberService; import org.springframework.beans.factory.annotation.Autowired; import org.springfram.. 2023. 7. 4. ์ด์ 1 2 3 4 ๋ค์