2016년 11월 28일 월요일

[자바강의,스프링강의,JPA강의추천_탑크리에듀][스프링JPA]Querydsl,SQLQueryFactory사용위한메이븐설정,pom.xml

[스프링JPA]Querydsl,SQLQueryFactory사용위한메이븐설정,pom.xml 

 DB스키마 구조대로 자바쪽에 쿼리 타입(Query Type)을 생성해야 하므로 querydsl-maven-plugin 플러그인을 추가해야 하고, Spring Data JPA에서 SQLQueryFactory를 이용하여 Native SQL을 JPA 메소드 기반으로 실행하기 위해 기존 Querydsl 설정에 추가로 querydsl-sql-spring 의존성과 쿼리 타입의 Hibernate Validation을 위해  hibernate-validator 추가해야 한다. 


[pom.xml] 

<?xml version="1.0" encoding="UTF-8"?> 
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 
<modelVersion>4.0.0</modelVersion> 

<groupId>ojc.edu</groupId> 
<artifactId>ojc.nativesql</artifactId> 
<version>0.0.1-SNAPSHOT</version> 
<packaging>jar</packaging> 

<name>nativesql-exam1</name> 
<description>jpa native sql example</description> 

<parent> 
<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-starter-parent</artifactId> 
<version>1.3.3.RELEASE</version> 
<relativePath /> <!-- lookup parent from repository --> 
</parent> 

<properties> 
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
<java.version>1.8</java.version> 
<querydsl.version>4.0.8</querydsl.version> 
</properties> 

<dependencies> 
<dependency> 
<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-starter-data-jpa</artifactId> 
</dependency> 

<dependency> 
<groupId>mysql</groupId> 
<artifactId>mysql-connector-java</artifactId> 
<version>5.1.38</version> 
<scope>runtime</scope> 
</dependency> 
<dependency> 
<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-starter-test</artifactId> 
<scope>test</scope> 
</dependency> 
<dependency> 
<groupId>com.querydsl</groupId> 
<artifactId>querydsl-jpa</artifactId> 
<version>${querydsl.version}</version> 
</dependency> 
<dependency> 
<groupId>com.querydsl</groupId> 
<artifactId>querydsl-sql-spring</artifactId> 
<version>${querydsl.version}</version> 
</dependency> 
<dependency> 
<groupId>org.hibernate</groupId> 
<artifactId>hibernate-validator</artifactId> 
</dependency> 
</dependencies> 
<build> 
<plugins> 
<plugin> 
<groupId>org.springframework.boot</groupId> 
<artifactId>spring-boot-maven-plugin</artifactId> 
</plugin> 
<plugin> 
<groupId>com.querydsl</groupId> 
<artifactId>querydsl-maven-plugin</artifactId> 
<version>${querydsl.version}</version> 
<executions> 
<execution> 
<goals> 
<goal>export</goal> 
</goals> 
</execution> 
</executions> 
<configuration> 
<jdbcDriver>com.mysql.jdbc.Driver</jdbcDriver> <jdbcUrl>jdbc:mysql://localhost/nativesql1?createDatabaseIfNotExist=true</jdbcUrl> 
<jdbcUser>root</jdbcUser> 
<jdbcPassword>1111</jdbcPassword> 
<packageName>jpa.model</packageName> 
<targetFolder>target/generated-sources/java</targetFolder> 
<namePrefix>S</namePrefix> 
<!-- targetFolder에 Dept.java, Emp.java를 생성 --> 
<exportBeans>true</exportBeans> 
</configuration> 
<dependencies> 
<dependency> 
<groupId>mysql</groupId> 
<artifactId>mysql-connector-java</artifactId> 
<version>5.1.38</version> 
<scope>compile</scope> 
</dependency> 
</dependencies> 
</plugin> 
</plugins> 
</build> 
</project>

댓글 없음:

댓글 쓰기