본문 바로가기

Spring&Spring Boot14

(Spring)(Pageable) Page<F>에서 Page<T>로 바꾸는 클래스 public class TypeTranslator { public static Page domainPageToDTOPage(Page domainPage, String dtoClassName) throws ClassNotFoundException, IllegalAccessException, InstantiationException { List dtoList = new ArrayList(); Class dtoClass = Class.forName(dtoClassName); for (F e : domainPage) { Object dto = dtoClass.newInstance(); BeanUtils.copyProperties(e, dtoClass.cast(dto)); dtoList.add((T) dto); .. 2019. 6. 18.
(Spring)(Pageable) Page 객체의 구현체 PageImpl의 커스터 마이징 @JsonIgnoreProperties(value = {"pageable", "last", "totalPages", "totalElements", "size", "number", "first", "numberOfElements", "sort", "empty"}) public class CustomPageImpl extends PageImpl { @JsonCreator public CustomPageImpl(List content, Pageable pageable, long total) { super(content,pageable.getSort().isSorted() ? pageable : PageRequest.of(pageable.getPageNumber(), pageable.getPageSize(), .. 2019. 6. 18.
(Spring) Spring IOC , Spring DI Spring IOC : (Inversion Of Control) 제어의 역전 Ex) DAO 클래스의 DB커넥션 얻어오는 메소드. -> 커넥션 얻어오는 기능을 하는 Conn 클래스로 분리 -> DAO 클래스는 Conn 클래스를 받아 DB와 연결 후 기능 수행 (생성자나 메소드로 받음) -> 받는 부분을 Conn 인터페이스로 한다면 Conn 구현체를 바꿔가며 사용할 수 있어서 DAO는 연결설정과 관련없이 동작가능 원래는 Conn 클래스를 new하는 형식으로 구현되어있겠으나(직접 생성 및 사용) 이것을 위처럼 바꾸면 제 3자가 Conn 클래스를 넘겨주는 것이므로 제어가 역전되었다고 하는 것이다! (오브젝트에 대한 제어권이 넘어감) Spring DI : (Dependency Injection) 의존 관계 주입 .. 2019. 4. 8.
(Spring Boot) 사용자 Class를 Bean 객체로 간단하게 설정하기 / Bean 객체 등록 사용자 클래스의 Spring Bean 등록/설정먼저 사용자 클래스를 Spring Bean 으로 등록하는 쉬운 방법은 클래스 선언부 위에 @Component 어노테이션을 사용하는 것 입니다. @Component 어노테이션이 붙은 클래스는 Spring Bean 객체로 등록이 되어 객체 생성/삭제를 Spring에서 관리하게 되겠죠? @Component public class MyClass { // Methods .... } Spring Boot로 서비스를 구현 하는 중에, 제가 구현한 Class를 Bean객체로 사용하고싶었지만 해당 Class의 field 1을 Autowired로 가지고, field 2를 Instance화 하는데에 또 다른 Bean Class의 Instance 객체가 필요한 특수한 상황이라 쉽.. 2018. 10. 31.
(Spring Boot) @Transactional 이란? / @Transactional에 대하여 @Transactional 관련글 ↓ @Transactional 전파 유형: https://lion-king.tistory.com/47 @Transactional 격리 레벨: https://lion-king.tistory.com/48 StackOverflow 질문중 UserNameNotFoundException 발생시 delete method가 실행되지않는다는 질문에 답을 하였습니다.https://stackoverflow.com/questions/52619924/how-to-execute-transaction-in-hibernate-while-throwing-exception/52620514#52620514 I have the following method in my transactional servic.. 2018. 10. 10.