2014-11-05 3 views
-2

저는 jsf와 java를 처음 사용하고 jpf와 jpql을 사용하여 jsf로 웹 프로젝트를 구축하고 있습니다. 지금 JPQL 쿼리를 작성하는 내 프로젝트에서 나는 다음과 같이 수행Querydsl jpa 시작하기

Query q = em.createQuery("SELECT a FROM Advert as a where a.razdel like ?1 and a.categoryId like ?2" ); 

하지만 그 쿼리 DSL 사용에 더욱 더 convient입니다 읽었습니다. 그래서 나는 몇 가지 튜토리얼을 읽은이가 발견

Add the following dependencies to your Maven project and make sure that the Maven 2 repo of Mysema Source (http://source.mysema.com/maven2/releases) is accessible from your POM : 



<dependency> 
    <groupId>com.mysema.querydsl</groupId> 
    <artifactId>querydsl-apt</artifactId> 
    <version>${querydsl.version}</version> 
    <scope>provided</scope> 
</dependency>  

<dependency> 
    <groupId>com.mysema.querydsl</groupId> 
    <artifactId>querydsl-jpa</artifactId> 
    <version>${querydsl.version}</version> 
</dependency> 

<dependency> 
    <groupId>org.slf4j</groupId> 
    <artifactId>slf4j-log4j12</artifactId> 
    <version>1.6.1</version> 
</dependency> 

그러나이 설정을 추가? 내 프로젝트에서 web.xml, persistence.xml 만 있습니다. 그게 전부입니까?

+1

It 's Maven. 그러므로 [Maven] (http://maven.apache.org/)을 배우거나 다른 튜토리얼을 찾으십시오. –

답변

1

는이 같은 섹션에있는 파일 pom.xml이를 추가 할 수 있습니다

<dependencies> 
    // add the stuff here 
</dependencies> 

당신은 아마 <property>${querydsl.version}에 대한 값을 정의해야이 작업을하려면. 이것은이 유사하게 나타납니다

<properties> 
    <querydsl.version>THE_REAL_VERSION_NUMBER</querydsl.version> 
</properties> 

그것은 당신이 또한 파일을 다운로드 할 수있는 저장소를 추가해야 할 것 같습니다 :

<repositories> 
    <repository> 
     <id>Mysema Source</id> 
     <name>Mysema Source - Releases</name> 
     <url>http://source.mysema.com/maven2/releases)</url> 
    </repository> 
</repositories> 

당신이 pom.xml이없는 경우를, 당신이 돈 ' Maven 기반 프로젝트가 있습니다. 이 경우 Maven 튜토리얼을 읽어야한다. 당신은 메이븐을 사용하지 않으려면

, 당신은 수동으로 필요한 라이브러리 jar 파일을 다운로드하여 웹 응용 프로그램의 WEB-INF/lib 폴더에 넣을 수 있습니다.