분류 전체보기

compileOnly This is where you declare dependencies which are required at compile time, but not at runtime. This typically includes dependencies which are shaded when found at runtime. 런타임할때는 필요없고 컴파일때만 필요할 경우 사용한다. plugins { id 'org.springframework.boot' version '2.7.4' id 'io.spring.dependency-management' version '1.0.14.RELEASE' id 'java' } group = 'study' version = '0.0.1-SNAPSHOT' sourceComp..
새로운 프로젝트를 하다가 롬복이 적용이 안될 때가 있다. 이때 해결했던 방법을 기록하고자 한다. 1. 라이브러리에 lombok이 잘 들어가있나 확인해야한다. 왜냐하면 가끔 수동으로 입력할때 실수로 gradle입력을 잘못하여 lombok이 추가되지않았을 수 있기때문이다. annotationProcessor 'org.projectlombok:lombok' compileOnly 'org.projectlombok:lombok' 롬복은 이 두개를 모두 입력해야한다. 2. 인텔리j를 업데이트한다.
의 type 에는 submit , reset, button 이 있는데 아무것도 명시하지 않은 일 경우 submit을 작동한다.
public interface MemberRepository extends JpaRepository { List findByUserNameAndAgeGreaterThan(String username, int age); List findHelloBy(); } public class Member { @Id @GeneratedValue @Column(name = "member_id") private Long id; private String name;//필드명 수정 private int age; . . . . . . 오류코드: Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'memb..
@Test public void findHelloBy() { List helloBy = memberRepository.findHelloBy(); } 해당 코드를 실행하면 정상적으로 작동 하는 것을 알 수 있다. 하지만 조금 의아하기도 하다. 왜냐하면 hello라는 의미없는 문자가 들어갔기 때문이다. 하지만 이는 틀린 문법이 아니다. Spring Data Jpa에서 지원하는 문법이다. reference doc에서는 다음과 같이 설명하고 있다. . Any text between find (or other introducing keywords) and By is considered to be descriptive unless using one of the result-limiting keywords such ..
List findByUserNameAndAgeGreaterThanAndNameLikeAndXXXAndXXXXAndXXX(String username, int age,int x, int y); 이런 식으로 And가 무한정으로 길어지면 사용하기도 보기도 너무 안좋기 때문에 Query-creation은 두개 정도가 적당하다
SELECT * FROM customer WHERE cust_country IN ('JP', 'KR', 'US'); jpa의 List(컬렉션)를 넘기고 싶을 때가 있는데 그때는 in을 쓰면 된다. em.createQuery("select c from customer where c.cust_country IN (:countrys)") .setParameter("countrys",countrys) .getResultList(); ↓ public interface CountryRepository extends JpaRepository { List findByCountryIn(Collection countrys) } 간단하게 바꿀 수 있다. 자세한 사용법은 아래 주소를 확인 해보자. https://docs.sp..
//==JPQL==// public List findByUsernameAndAgeGreaterThan(String userName, int age) { return em.createQuery("select m from Member m where m.userName = : username and m.age > : age") .setParameter("username", userName) .setParameter("age", age) .getResultList(); } ↓ public interface MemberRepository extends JpaRepository { List findByUserNameAndAgeGreaterThan(String username, int age); } jpql: fin..
키보드발
'분류 전체보기' 카테고리의 글 목록 (14 Page)