본문 바로가기

Language/Java, Android

(54)
IntelliJ cannot resolve symbol.. 에러 해결 문제 IntelliJ IDEA를 쓰고 있으며, 멀쩡히 잘 쓰다가 종종 잊을만하면 Cannot resolve symbol.. 에러가 나온다. 예를 들면 아래와 같이 import가 제대로 안되는 것이다. cannot resolve symbol import org.openjdk.jmh.runner.options.Options; build.gradle 설정을 제대로 안해줬나? 싶어서 암만 뒤져봐도 잘못된게 없어보이고, 한참 생각하다가 ‘아 또 그거냐..하..’ 하게 되는에러다. 매번 검색하기 귀찮아서 따로 정리해두기로 했다. 해결 1차 시도 상단 메뉴바에서 Build > Clean Project 하고나서 Build > Rebuild Project를 한다. 2차 시도 1차 시도로 해결이 안되면 캐시를 비우고 재실..
MacOS 에서 H2 database 설치 및 Spring Boot 에 연결 1. H2 Database 홈페이지에서 다운로드 다운로드 링크 : https://www.h2database.com/html/main.html 최신 버전보다는 안정화된 버전이 괜찮습니다. 2. 압축 풀고 실행 다운 받은 파일의 압축을 풀면 다음과 같은 구성으로 되어 있습니다. 여기서 ./bin/h2.sh 를 입력하면 h2 console 을 실행합니다. 만약 권한이 없으면 chmod 755 ./bin/h2.sh 로 권한을 부여합니다. 3. 한번 연결해서 ~.mv.db 파일 생성 후 실행 처음 진입하면 아래와 같은 화면이 나옵니다. 다른 칸은 전부 그대로 두고 JDBC URL 부분만 표시한 것처럼 바꿔줍니다. 그리고 연결 버튼을 눌러서 진입합니다. 그럼 다음과 같이 내 Root 폴더에 my-db-test.mv..
[Lombok] @Builder 사용 시 @NoArgsConstructor 관련 에러 해결 Spring Boot로 개발 시 Lombok의 @Builder를 사용할 때 자주 마주치는 에러가 있다. 바로.. 아래와 같은 에러 ! 에러 Error:(7, 1) java: constructor MyName in class kr.leocat.test.MyName cannot be applied to given types; required: no arguments found: java.lang.String,java.lang.String reason: actual and formal argument lists differ in length 원인 원인은 @Builder를 사용 시 @NoArgsConstructor 어노테이션을 함께 사용해서 에러가 발생한다. 모든 멤버변수를 받는 생성자가 없는 것이 이유이다. ..
[JPA] Spring Data JPA와 QueryDSL 이해, 실무 경험 공유 Spring Data JPA와 QueryDSL JPA 기반 프로젝트 Spring Data JPA QueryDSL Spring Data JPA 지루하게 반복되는 CRUD 문제를 세련된 방법으로 해결 개발자는 인터페이스만 작성한다 스프링 데이터 JPA가 구현 객체를 동적으로 생성해서 주입 스프링 데이터 JPA 적용 전public class MemberRepository { public void save(Member member) {...} public Member findOne(Long id) {...} public List findAll() {...} public Member findByUsername(String username) {...} }public class ItemRepository { publ..
Spring Data JPA 사용 시 deleteById 와 delete 의 차이 Spring Data 란? Spring Data’s mission is to provide a familiar and consistent, Spring-based programming model for data access while still retaining the special traits of the underlying data store. It makes it easy to use data access technologies, relational and non-relational databases, map-reduce frameworks, and cloud-based data services. This is an umbrella project which contains many subprojec..
[ERROR] Can not issue data manipulation statements with executeQuery(). @Modifying 사용하기 Can not issue data manipulation statements with executeQuery(). Servlet.service() for servlet [dispatcherServlet] in context with path threw exception [Request processing failed; nested exception is org.springframework.orm.jpa.JpaSystemException: could not extract ResultSet; nested exception is org.hibernate.exception.GenericJDBCException: could not extract ResultSet] with root cause @Query(valu..
[JPA] 특정 칼럼을 제외하고 INSERT, UPDATE하는 방법 보통 JPA는 SAVE시에 모든 칼럼을 INSERT한다. 그럴 경우, NOT NULL로 설정된 칼럼은 기본값으로 삽입되는것이 아닌 NULL로 삽입을 시도한다. 이로 인해 에러가 발생하는데, 이럴 경우에 아예 쿼리에서 빼버려서 실행이 안되게 만들 수 있다. 쿼리에서 제외된 칼럼은 DB에 지정된 default값으로 삽입이 된다. 특정 칼럼을 제외하고 save하는 방법은 다음과 같다. @Column(insertable=false, updatable=false) private String defaultField; [출처] https://jobc.tistory.com/129
Spring JPA 2 - Spring Data JPA, Spring Data JPA CRUD [Spring] Spring JPA 2 - Spring Data JPA, Spring Data JPA CRUD Spring Data JPA Spring Data - 데이터에 접근하는 코드를 줄이기 위한 스프링 프로젝트 - DDD(Domain-Driven Design, 도메인 주도 설계)에서의 데이터 접근 계층 구성 요소인 Repository 권장 - Repository 구현은 데이터와 관련된 아키텍쳐/제품에 따라 다름(각 종류별로 프로젝트가 만들어짐) Spring Data JPA - JPA를 이용해 데이터에 접근하기 위한 라이브러리 - Respository 인터페이스를 작성하여 간단하게 Entity를 참조/갱신할 수 있음 JPA Config 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15..