일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 순환문
- 공부
- 이클립스단축기
- 백준문제
- 별 찍기
- 오류
- 오라클
- 설정
- 파워서플라이
- spring
- MSI
- ORA-02292
- 스프링
- while
- ORA-01407
- 환경설정
- for문
- 오류모음
- Ajax
- 백준문제풀이
- Oracle
- 백준
- 자바
- 무결성 제약조건
- 인터페이스
- 이클립스
- 전화번호부
- jsp
- 깃허브 블로그
- 티스토리 블로그
- Today
- Total
목록Spring 입문 (12)
danDevlog
성능(시간)을 알아보기 위해 모든 메소드의 호출 시간을 측정하고 싶다면? package hello.hellospring.service; @Transactional public class MemberService { /** * 회원가입 */ public Long join(Member member) { long start = System.currentTimeMillis(); try { validateDuplicateMember(member); //중복 회원 검증 memberRepository.save(member); return member.getId(); } finally { long finish = System.currentTimeMillis(); long timeMs = finish - start; S..
JPA를 이용하면 기존의 반복 코드는 물론, 기본적인 SQL도 JPA가 직접 만들어서 실행해준다. SQL과 데이터 중심의 설계에서 객체 중심의 설계로 패러다임을 전환 할 수 있고, 개발 생산성을 크게 높일 수 있다. build.gradle 파일에 JPA와 H2 관련 라이브러리를 추가해준다. implementation 'org.springframework.boot:spring-boot-starter-data-jpa' runtimeOnly 'com.h2database:h2' application.properties 파일에 설정을 추가해준다. spring.jpa.show-sql=true spring.jpa.hibernate.ddl-auto=none show-sql 은 JPA가 생성하는 SQL을 출력해준다. d..
순수 JDBC를 이용해서 만든 결과물을 스프링 컨테이너와 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.Trans..

개발 및 테스트 용도로 가볍고 편리한 DB및 웹 화면을 제공해주는 H2 DB를 사용한다. 최근 버전이아닌 1.4.200버전을 이용한다. (스프링 부트 버전에 맞춰서) -윈도우 설치 방법- https://www.h2database.com/html/download-archive.html Archive Downloads www.h2database.com 위 링크로 들어가서 파일을 다운로드한다. 파일을 설치 후 h2.bat이 있는 파일경로(C:\Program Files (x86)\H2\bin) 까지 간 다음에, h2.bat을 실행한다. 그러면 이러한 화면이 자동으로 웹브라우저에 발생하는데 JDBC URL 부분에 jdbc:h2:~/test (최초 한번) 으로 연결을 한 번 해준다. 연결 후, 사용자명 폴더 안에 ..

구현한 기능들을 웹 브라우저에서 제대로 잘 작동하는지 화면을 만들어준다. -홈 화면- 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"; } } 스프링 빈에 등록될 수 있게 @Controller 어노테이션을 달아주고, @GetMapping을 통해 주소와 매핑한다. 리턴으로 home이라는 이름의 뷰를 리턴하므로, home.html..
자바 코드로 직접 스프링 빈 등록 직접 스프링 빈에 등록하기 위해서 컴포넌트 스캔 방식을 사용할때 추가했던 어노테이션들(@Service, @Autowired, @Repository) 들을 삭제해준다 (@Controller는 제외) 그런 다음 service 패키지 내에 SpringConfig라는 자바클래스를 작성한다. package hello.hellospring; import hello.hellospring.repository.MemberRepository; import hello.hellospring.repository.MemoryMemberRepository; import hello.hellospring.service.MemberService; import org.springframework.cont..