본문 바로가기
반응형

전체 글149

[Java] 입력할 때 날짜규칙 설정: 허용 O or X - dateFormat.setLenient(false) 날짜에 대해 규칙을 주고 해당 규칙에 맞게 입력값을 주고 싶을때 date.setLenient(false)를 사용한다. lenient는 관대한이라는 뜻이다. false이니 허용하지 않는다고 보면 된다. 날짜 입력에서 규칙에 어긋나면 parse할 때 에러를 잡도록 했다. public static boolean validationDate(String checkDate) { try { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); dateFormat.setLenient(false); dateFormat.parse(checkDate); return true; } catch (ParseException e) { throw new RuntimeE.. 2023. 1. 13.
JavaScript: html 가져와서 내용 확인 ex: document.querySelector() js에서 html을 가져와서 내용을 확인하고 싶을 경우 여러가지 방법이 있겠지만 몇가지 방법을 소개하고자 한다. document.getElementById(); document.getElemensByClassName(); document.querySelector(); document.getElementById(); // html에서 id 값을 가져오고 싶을 경우 사용 document.getElemensByClassName(); // html에서 특정한 element 값으로 되어 있는 여러 element를 한번에 가져오고 싶을 경우 사용 document.getElementsByTagName(); // tag name에 대해서 array로 값을 가져옴 document.querySelector(); // el.. 2023. 1. 13.
html(thymeleaf) 이미지 2개를 나란히 배치 html에서 이미지 2개를 나란히 배치하는 경우가 있다. div로 묶고 각각의 이미지에 float:left를 적용하면 된다. 상품이미지 2023. 1. 10.
[Mac] Intellij 코드 자동 정렬 단축키 [Mac] Intellij 코드 자동 정렬 단축키 option + command + L 2023. 1. 7.
[JAVA] List, ArrayList 차이 ArrayList list = new ArrayList (); List list = new ArrayList (); List, ArrayList의 차이를 알아보려 한다. List는 인터페이스로 되어있고, ArrayList는 클래스로 되어있다. List list = new ArrayList (); 인터페이스인 List에 ArrayList를 assign하는 식으로 구현한다. 이렇게 많이 쓴다. 코드가 유연해지기 때문이다.(제네릭, 다형성 사용) 2023. 1. 4.
java entity -> dto 변환 stream, map, collect 사용 - 동작원리(1) jpa를 사용하다가 entity에 dto를 적용할 때가 있었다. entity를 dto로 변환하는 과정에서 stream, map, collect를 사용하였다. 동작원리를 알아보자. 코드는 AppointmentQueryService 클래스에서 findAppointmentByEmail() 메서드를 살펴보겠다. findAppointmentByEmail() 메서드: 해당 email 멤버에 대한 예약 내역을 가져오는 메서드 @Service @Transactional(readOnly = true) @RequiredArgsConstructor public class AppointmentQueryService { private final AppointmentRepository appointmentRepository; p.. 2023. 1. 2.
jasypt 에러: Failed to bind properties under 'spring.datasource.password' to java.lang.String: 다음과 같은 에러가 발생했다. Failed to bind properties under 'spring.datasource.password' to java.lang.String 패스워드가 비워져 있어서 생긴 에러라고 한다. JasyptConfig 클래스는 고칠게 없어 보인다. @Configuration public class JasyptConfig { @Value("${jasypt.encryptor.password}") private String PASSWORD; @Bean("jasyptStringEncryptor") public StringEncryptor stringEncryptor() { PooledPBEStringEncryptor encryptor = new PooledPBEStringEncrypt.. 2022. 12. 29.
MyBatis란(SQL Mapper) MyBatis란? - 자바에서 SQL Mapper를 지원해주는 프레임워크 - JDBC를 통해 데이터베이스에 엑세스하는 작업을 캠슐화한다. - 일반 SQL 쿼리, 저장 프로시저, 고급 매핑을 지원한다. - 프로그램에 있는 SQL 쿼리를 한 구성파일에 구성하여 프로그램 코드와 SQL을 분리할 수 있다. - SQL을 직접 작성해서 쿼리 수행 결과를 객체와 매핑한다 - 쿼리문을 XML로 분리 가능하다 MyBatis: 장점: - 자바의 관계형 데이터베이스 프로그래밍을 쉽게 할 수 있도록 도와준다. - 모든 JDBC 코드, 매개 변수의 중복작업을 제거한다. - 복잡한 쿼리 작성이 가능하다 - 데이터 캐싱 기능으로 성능이 향상된다 MyBatis 단점: - 객체, 쿼리문을 모두 관리해야한다. - CRUD 메소드를 직접.. 2022. 12. 24.

반응형
반응형