전체 글

중요한 것은 꺾여도 그냥 하는 마음
1. xml 작성 logAroundAdvice logBeforeAdvice logAfterReturningAdvice logAfterThrowingAdvice xml에 사용할 어드바이스들의 객체를 생성하고,이를 proxy 핸들러에 주입해준다. 2. 핸들러 클래스 작성 1) Before Advice public class LogBeforeAdvice implements MethodBeforeAdvice{ @Override public void before(Method method, Object[] args, Object target) throws Throwable { // TODO Auto-generated method stub System.out.println("앞에서 실행될 로직"); } } 주기능을 ..
이전 강의에서는 JAVA 코드로 AOP를 구현했었는데, 이번엔 스프링으로 AOP를 구현해보겠다. 1. xml 설정 logAroundAdvice 스프링에서는 자동으로 인터페이스를 지정해주기 때문에 사용할 객체와 핸들러만 DI 해주면 된다. 여기서 핸들러를 설정할 때, property name으로 interceptorNames를 사용한다. 2. 핸들러 클래스 생성 public class LogAroundAdvice implements MethodInterceptor{ @Override public Object invoke(MethodInvocation invocation) throws Throwable { long start=System.currentTimeMillis(); //실제 업무를 담당하는 메소드를..
@Configuration 어노테이션을 사용하려는데 아래와 같은 에러가 발생했을 경우 Exception in thread "main" java.lang.IllegalStateException: CGLIB is required to process @Configuration classes. Either add CGLIB to the classpath or remove the following @Configuration bean definitions: 해당 프로젝트에 CGLIB 라이브러리를 pom.xml에 추가하면 해결된다. cglib cglib 2.2.2 -CGLIB 라이브러리 관련 Maven Repository URL https://mvnrepository.com/artifact/cglib/cglib
만약 B2에서 B3로 다른 객체를 주입해주고 싶은 경우 코드를 -> 로 수정해주면 된다. 하지만 이 역시 번거롭기 때문에 스프링 어노테이션을 사용하여 더 간략히 해보고자 한다. 위와같이 @Autowired 어노테이션을 사용하면 별도의 xml 파일 수정없이도 객체를 주입할 수 있다. 실습은 다음장에서 해보겠다.
util 네임스페이스를 사용하려고 xml 파일에 xmlns:util 구문을 추가했다. 하지만 프로그램 실행 시 아래와 같은 에러가 발생했다. 이를 해결하기 위해서는 ... 와 같이 xsi:schemaLocation에 util 네임스페이스와 관련된 http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-4.2.xsd 를 추가시키면 문제가 해결된다.
1. Application Context - ClassPathXmlApplicationContext : 프로젝트 폴더 루트 주소에 있는 xml 파일 사용 - FileSystemXmlApplicationContext : C 혹은 D 드라이브 등 파일 시스템에 있는 xml 경로 입력 후 사용 - XmlWebApplicationContext : 웹에 둔 xml을 사용 - AnnotationConfigApplicationContxt : xml을 사용하지 않고 어노테이션을 이용하여 환경설정을 함 2. Application Context 사용을 위한 메이븐을 통한 Spring context 추가 https://mvnrepository.com/search?q=spring+context 버전 선택 후 위의 코드를 po..
· Git&Github
0. git 설치 https://git-scm.com/download/win Git - Downloading Package Download for Windows Click here to download the latest (2.41.0) 32-bit version of Git for Windows. This is the most recent maintained build. It was released 11 days ago, on 2023-06-01. Other Git for Windows downloads Standalone Installer 32-bit Git for Win git-scm.com 자신 컴퓨터 환경에 맞는 git 버전을 설치한다. 1. git init git bash를 실행시키고 프로젝트..
위와 같이 Eclipse에서 실행 시 404에러가 뜨는 경우가 있다. 이 때는 아래와 같이 해당 프로젝트를 우클릭 한 후 properties => java build path => libraries => add library => server runtime => tomcat 등록 과정을 거치면 해당 프로젝트에 톰캣이 등록되어 문제가 해결된다.
1. 코드에서 주업무 로직인 Core Concern과 보조 업무인 Cross-cutting Concern 으로 나누기 public class NewlecExam implements Exam{ public int total(){ long start = System.currentTimeMillis(); SimpleDateFormat dayTime = new SimpleDateFormat("yyyy-mm-dd hh:mm:ss"); String str = dayTime.format(new Date(start)); System.out.println(str); /*--------------------------------------------------------------------*/ int result = k..
1. OOP와 AOP OOP(Object Oriented Programming) : 사용자가 원하는 업무 기반의 로직에 관심(사용자 요구사항) - 주 업무 로직 AOP(Aspect Oriented Programming) : 개발자/운영자가 운영할 때 필요에 따라 끼어놓는 코드 - 주 업무는 아니지만 OOP ⊂ AOP : AOP가 더 큰 범위 2. Primary Core Concern과 Cross-cutting Concern Primary Core Concern : 주 업무 로직을 담당 Cross-cutiing Concern : 로그처리, 보안처리, 트랜잭션처리 등 주 업무 로직은 아니지만 반복되는 필요한 작업 매 주 업무 로직마다 위 내용들을 처리하는 코드를 삽입하지 않고 중간에 Proxy를 두어 이들을..
째로스
개발일지