본문 바로가기

전체 글83

spring - aop 직접 구현해보기 1. 공통 코드의 분리 → 여러 메서드에 공통 코드를 추가해야 한다면?class MyClass { void syrian() { System.out.print("Syrian() is called "); } void dwarf() { System.out.print("Dwarf() is called "); } void geobil() { System.out.print("Geobil() is called "); } } 이렇게 출력하는(메인기능) serian, dwarf, geobil이라는 세가지 메서드가 있을때 메서드의 앞뒤로 특정문구(부가기능)를 추가로 넣어주려면  class MyClass { void syrian() { System.out.println("[Before] "); System.out.pri.. 2024. 7. 10.
spring - Junit으로 테스트해보기 TDD는 Test-Driven Development(테스트 주도 개발)을 말하는데 말그대로 코드를 테스트 하는 것 테스트로 사용하는 프레임워크는 Junit, Spring test1. Junit은 단위테스트로 주로 사용2. Spring test는 애플리케이션 통합테스트를 하는 용도라고 한다. 사실 대략적으로만 이렇게 알고 있어서 자주 써보면서 알아가야 될거같다. 스프링부트에선 비교적 간편했는데 스프링에서는 못 써봤다.최프때 쓰려고 하다가 설정에서 꼬이고 계속 시간 뺐겨 가지고 쌤한테 물어봤는데 설정파일 얘기하시고 안 알려주시더라 설정파일 문제인건 알고 있었고 그 부분을 해결 못했던건데..ㅋㅋ제대로 해결을 못해서 포기하고 이제서야 정리한다. src/main/java 경로가 아닌 src/test/java 패키.. 2024. 7. 9.
spring - mysql 연결(2) 클래스파일에 직접 설정해서 않고 root-context.xml 파일에 빈객체 작성해서 연결해본다. 먼저 root-context.xml 파일에 드라이버 정보를 작성root-context.xml  연결 클래스 생성public class DBConnectionTest2 { public static void main(String[] args) throws Exception { ApplicationContext ac = new GenericXmlApplicationContext("file:src/main/webapp/WEB-INF/spring/**/root-context.xml"); // 1.GenericXmlApplicationContext 클래스를 사용해서 Sprin.. 2024. 7. 9.
spring - mysql 연결(1) public class DBConnectionTest { public static void main(String[] args) throws Exception { String DB_URL = "jdbc:mysql://localhost:3306/springbasic?useUnicode=true&characterEncoding=utf8"; → mysql(jdbc:mysql://[host]:[port]/[database]?useUnicode=true&characterEncoding=utf8) String DB_URL = "jdbc:oracle:thin:@localhost:1521:orcl"; → oracle(jdbc:oracle:thin:@[host]:[port]:[SID]) .. 2024. 7. 9.