목록2024/07/04 (4)
wintertreey 님의 블로그
MyBatis란?MyBatis는 자바 개발자들이 데이터베이스를 쉽게 다룰 수 있도록 도와주는오픈 소스 ORM(Object-Relational Mapping) 프레임워크이다. MyBatis의 주요 장점유연성: SQL 쿼리를 직접 작성할 수 있으므로 매우 유연하다. 또한, MyBatis는 동적 쿼리를 작성할 수 있다.간결성: MyBatis는 SQL 쿼리와 프로그래밍 언어 코드를 분리하기 때문에 코드가 간결해져 유지보수에 용이성능: MyBatis는 캐시 기능을 제공하여 데이터베이스 연산 속도를 높일 수 있다.다양한 데이터베이스 지원: MyBatis는 다양한 데이터베이스에 대한 지원을 제공한다. Configuration.xml m..
이번에는 Constructor Injection, Setter Injection 모두 적용시켜보자. Sum up! 기본 작업pom.xml - maven 작업. dependencies 넣어주기 분류작업을 위해 package model, controller, other를 만들어주었다. Model 부터 시작인터페이스 & 클라스 생성하기. MyInfoInter.javapackage pack.model;public interface MyInfoInter { String myData();} MyInfo.javapackage pack.model;public class MyInfo implements MyInfoInter { @Override public String myData() { return "취미는 ..
우리가 Spring을 사용하는 수 많은 이유중에 대표적인 장점을 꼽으라면 의존성 주입 컨테이너에 관한 내용을 빼놓을 수 없다. 스프링은 자바 빈을 찾아서 ApplicationContext라고 하는 의존성 주입 컨테이너 오브젝트에 등록을 한다. 그리고 애플리케이션이 돌다가 어떤 오브젝트가 필요하다면 의존하는 오브젝트를 찾아서 연결해준다. 그렇다면 스프링은 어떻게 자바 빈을 찾아가지고 의존성 주입 컨테이너에 등록하는걸까?? @Component 어노테이션으로 이 클래스를 자바 빈으로 등록하라고 알려줄 수 있다. @Component@Component 어노테이션을 붙이면 이 클래스를 자바 빈으로 등록시키라고 알려줄 수 있다. 해당 어노테이션이 명시되어 있으면 Spring이 자동으로 클래스의 인스턴스를 생성해준다...
앞서 constructor injection에 대해서 실습해보았다. 이번엔 setter injection. 생성자의 경우 객체생성을 1번만 할 수있다.그에 반해 setter의 경우 생성자보다 더 유연하다는 장점이 있다. 연습pom.xmlmaven 프로젝트이기에 dependency 부분 추가해서 넣어준다. ShowData.javapackage pack;public class ShowData { public String processNickName() { return "홍길동"; } public String processHobby() { return "프로그래밍 만들기"; }} MyProcess.javapackage pack;public class MyProcess { //DI 중 setter i..