본문 바로가기

spring8

spring pom.xml 스프링 빈 객체의 초기화와 소멸 어노테이션 방식 인터페이스를 구현하여 초기화와 소멸 방식 @Service public class MemberService implements InitializingBean, DisposableBean { @Autowired MemberRepository memberRepository; String str; @Override public void afterPropertiesSet() throws Exception { str = "jdbc:mysql://192.168.0.38"; // 긴 문자열을 재정의 할때 System.out.println("IOC 컨테이너 들어갈때.."); } @Override // public void destroy() throws Exception {.. 2024. 2. 28.
spring 등록 출력(복습) spring Main -> MemberService -> Member DAO spring boot MemberController -> MemberService -> MemberRepository 순서는 이렇게 만든다. fackage 를 이렇게 만들어준다 ●MyConf package org.example.Conf; import org.example.component.AABBService; import org.example.member.MemberDao; import org.example.member.MemberService; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.context.anno.. 2024. 2. 27.
spring 으로 게시판 ●Main package org.example; import org.example.Member.MemberDto; import org.example.Member.MemberService; import org.example.conf.MyConf; import org.springframework.context.annotation.AnnotationConfigApplicationContext; public class Main { private static AnnotationConfigApplicationContext acac = null; public static void main(String[] args) { acac = new AnnotationConfigApplicationContext(MyConf.cl.. 2024. 2. 23.
Spring 기초 메모리의 낭비를 방지 하기 위해 spring을 사용한다. ●xml 방식으로 객체 조립 resources 에 xml 파일을 만들어서 넣어준다 package org.example; import org.example.component.AA; import org.springframework.context.support.GenericXmlApplicationContext; public class Main2 { public static void main(String[] args) { GenericXmlApplicationContext context = new GenericXmlApplicationContext("myContext.xml"); AA a1 = context.getBean(AA.class); AA a2 .. 2024. 2. 22.