분류 전체보기 216

[스프링 부트] 게시판 무작정 따라하기 - 1. 글 작성 처리

DB연결 application.properties에 다음 내용 작성 spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.username=root spring.datasource.password=1234 spring.datasource.url=jdbc:mysql://localhost:3306/board BoardController 작성 package com.study2.board.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.spr..

24. AOP가 필요한 상황

AOP가 필요한 상황 모든 메서드의 호출 시간을 측정하고 싶을 때 공통 관심 사항(cross-cutting concern) vs 핵심 관심 사항(core concern) 회원 가입 시간, 회원 조회 시간을 측정하고 싶다면? MemberService 회원 조회 시간 측정 추가 package hello.hellospring.service; import hello.hellospring.domain.Member; import hello.hellospring.repository.MemberRepository; import hello.hellospring.repository.MemoryMemberRepository; import org.springframework.beans.factory.annotation.Aut..

18~23. 스프링 DB 접근 기술

H2 데이터베이스 설치 개발이나 테스트 용도로 가벼운 데이터베이스 https://h2database.com/html/main.html 에서 다운로드 가능 H2 Database Engine H2 Database Engine Welcome to H2, the Java SQL database. The main features of H2 are: Very fast, open source, JDBC API Embedded and server modes; in-memory databases Browser based Console application Small footprint: around 2.5 MB jar file size Supp h2database.com 압축을 풀고 h2.bat 실행하면 로그인 화면이 나..

15. 회원 웹 기능 - 홈 화면 추가

회원 웹 기능 - 홈 화면 추가 홈 컨트롤러 추가 package hello.hellospring.controller; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @Controller public class HomeController { @GetMapping("/") public String home() { return "home"; } } 회원 관리용 홈 Hello Spring 회원 기능 회원 가입 회원 목록 localhost:8080 요청 시 출력 페이지 회원 가입을 누르면 /members/new로 이동 회원 목록을 누르면 /members로 이동 하지만..

14. 자바 코드로 직접 스프링 빈 등록하기

수동으로 스프링에 등록하는 방법 MemberService와 MemberRepository의 @Service, @Repository, @Autowired 애노테이션을 제거하고 진행한다. package hello.hellospring; import hello.hellospring.domain.Member; import hello.hellospring.repository.MemberRepository; import hello.hellospring.repository.MemoryMemberRepository; import hello.hellospring.service.MemberService; import org.springframework.context.annotation.Bean; import org.spr..