분류 전체보기
-
Github Packages로 private maven repository 만들기빌드 자동화 도구/Gradle 2024. 7. 25. 16:39
업무 중에 두 프로젝트에서 공통된 부분을 어떻게 관리할 수 있을지 고민하던 중에 선택한 방법을 공유해봅니다. 글은 아래와 같은 순서로 진행됩니다.1. 작업을 시작한 배경2. 어떻게 개선할 것인가3. 로컬환경에서 publish 하기4. Github Packages 사용해서 gradle registry 만들기5. 라이브러리 적용하기6. 빈등록 이슈 해결7. CI/CD 파이프라인 생성 (optioanl) 1. 작업을 시작한 배경회사 코드를 바로 쓸 수 없으니, 비슷한 상황을 가정해보겠습니다저는 Greeting Project를 만들고 있습니다. 초기에는 간단한 기능들로 구성된 'Simple Server'를 구현해서 프로젝트를 운용 중이었습니다. 일을 하다보면 언제나 그렇듯.. 일정이 얼마남지 않은 ..
-
1.4.1 오브젝트 팩토리책/토비의 스프링 2024. 7. 8. 23:37
책을 읽고 흘려버리기 보단, 꼭꼭 씹어먹기 위해 정리해봅니다.이 포스팅은 이일민님의 에 기반하고 있습니다. 1. 문제의 상황어떤 Connection 구현 클래스를 사용할지 UserDao에서 결정하던 부분을 UserDaoTest로 이전해주었습니다.이번에는 UserDaoTest가 기능이 잘 동작하는지 테스트하는 것 + 사용될 클래스를 결정하는 것 이렇게 2가지일을 하게 되었습니다. 2. 해결방법새로운 클래스로 분리하기UserDao와 ConnectionMaker를 만드는 일, 그리고 두 객체의 관계를 맺는 일을 전담하는 클래스를 생성한다. 3. 팩토리 클래스를 만들기오브젝트를 생성하는 측과 사용하는 측을 분리하기 위해 만드는 목적!(추상 팩토리 패턴, 팩토리 메소드 패턴과 무관) 더보기public cla..
-
1.3.3 관계설정 책임의 분리책/토비의 스프링 2024. 7. 7. 16:10
책을 읽고 흘려버리기 보단, 꼭꼭 씹어먹기 위해 정리해봅니다.이 포스팅은 이일민님의 에 기반하고 있습니다. 1. 문제의 상황1) 클래스를 분리하였으나 여전히 UserDao가 특정 클래스의 이름에 대해 알아야함 2. 해결방법클래스 간의 관계 -> 오브젝트 간의 관계로 변경현재 UserDao는 new NConnectionMaker()를 생성자에서 실행함으로써, 어떤 ConnectionMaker를 사용할지 결정하고 있다.UserDao와 ConnectionMaker의 관계를 UserDao 속에서 결정하는 것이 아닌 외부의 다른 객체에서 진행한다. 3. 인터페이스와 의존성 주입을 통한 문제해결ConnectionMaker 인터페이스를 생성하여 고객사별로 구현을 하도록 만들고,UserDao는 ConnectionM..
-
1.3.1 클래스의 분리책/토비의 스프링 2024. 7. 7. 15:21
책을 읽고 흘려버리기 보단, 꼭꼭 씹어먹기 위해 정리해봅니다.이 포스팅은 이일민님의 에 기반하고 있습니다. 1. 기존 방법의 문제점책에서는 여러 가지 이유로 상속의 문제점에 대해서 이야기하고 있습니다. 하지만 언급하는 대부분의 내용들이 추상메소드를 상속하는 경우에는 해결이 되는 부분이라고 느껴져서 크게 와닿지 않았습니다. 특히 상속을 통한 상하위 클래스의 관계가 밀접하여 superclass를 변경할 경우 모든 서브클래스를 변경해야할 수 있다는 부분이있는데, 이 부분은 superclass 메소드의 시그니쳐가 바뀌지 않는한 subclass에서 변경을 신경쓸 필요가 없다고 생각이 듭니다. 만약 메소드의 시그니쳐가 바뀌는 경우라면, 인터페이스를 사용해도 동일한 부작용을 가져올 것이기 때문에 상속만의 문제는 아..
-
1.2.3 DB 커넥션 만들기의 독립책/토비의 스프링 2024. 7. 7. 14:42
책을 읽고 흘려버리기 보단, 꼭꼭 씹어먹기 위해 정리해봅니다.이 포스팅은 이일민님의 에 기반하고 있습니다. 1. 문제의 상황1) UserDao가 인기를 얻어 여러 회사에서 사용하고 싶어하는 상황2) 고객사별로 데이터베이스 연결에 대한 다양한 요청사항이 있음 MySQL, PostgreSQL 등 고객사별로 다양한 데이터베이스 사용 니즈혹은 동일한 데이터베이스를 사용해도 커넥션을 생성하는 로직이 상이함3) UserDao의 소스코드는 기밀이므로 고객사에 노출하지 않아야함 2. 해결방법고객사가 각자 회사의 입맛에 맞는 커넥션 로직을 구현할 수 있도록 방법을 제공하고, 구현된 로직을 UserDao에서 사용할 수 있도록 변경이 필요 3. 상속을 통한 문제해결2번의 해결방법을 추상메소드를 상속하는 방법으로 해결한다..
-
1.2.2 커넥션 만들기의 추출책/토비의 스프링 2024. 7. 7. 14:11
책을 읽고 흘려버리기 보단, 꼭꼭 씹어먹기 위해 정리해봅니다.이 포스팅은 이일민님의 에 기반하고 있습니다. 1. 문제의 상황데이터베이스 커넥션에 관련된 내용이 모든 메소드에 반복되고 있다.변경이 필요할 경우 모든 메소드를 변경해야하는 문제가 있다. 1. 개선 전메소드 add, get, deleteAll 모두 데이터베이스 커넥션에 대한 관심사가 포함되어 있다.더보기public class UserDao { public void add(User user) throws SQLException, ClassNotFoundException { Class.forName("com.mysql.jdbc.Driver"); Connection c = DriverManager.getConnection("jdbc:m..
-
1.1 초난감 DAO책/토비의 스프링 2024. 7. 7. 13:55
책을 읽고 흘려버리기 보단, 꼭꼭 씹어먹기 위해 정리해봅니다.이 포스팅은 이일민님의 에 기반하고 있습니다. 1. 클래스 구성1. User.java자바빈 규약을 따르는 클래스더보기public class User { private String id; private String name; private String password; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } public Str..
-
Kotlin & Spring 으로 Entity 생성하기프레임워크/Spring Boot 2024. 7. 1. 21:01
자바로 spring을 시작했는데, 회사에서는 코틀린을 쓰게 되었습니다~비슷할 거라고 생각하고 작업을 하지만, 예상치 못한 곳에서 번거로움이 있어서 업무 속도가 안나옵니다! ㅠ어떻게 하는게 좋을까 고민을 해보며 글을 적어봅니다! 1. 주 생성자를 사용해서 엔티티 생성이 방법이 처음 사용한 방법이고 가장 기본적인 방법이라고 생각이 들었습니다.@Entity@Table(name = "lectures")class Lecture( @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "lecture_id") val lectureId: Long, @Column(name = "lecture_name", nullable..