Quarkus mybatis

csm·2021년 10월 29일

quarkus

목록 보기
3/4

개요

Quarkus 에서 jpa 가 아닌 mybatis 구성 이력을 남겨본다.
기억에 의존하여 작성하였다.

작업내용

  • build.gradle
    implementation 'io.quarkiverse.mybatis:quarkus-mybatis-parent:0.0.9'
    implementation 'io.quarkiverse.mybatis:quarkus-mybatis:0.0.9'
    //compile 'io.quarkus:quarkus-hibernate-validator:1.13.6'
    compile ('io.quarkus:quarkus-hibernate-validator:1.13.6') {
        exclude group: "com.sun.jersey"
    }
  • Mapper.java
@Mapper
public interface Mapper {
	
	@Select("select"
			+ "	key, refer"
			+ " from"
			+ "	reply"
			+ "	and regdate > STR_TO_DATE(#{minDate}, '%Y%m%d')"
			+ "	and key = #{key}"
			+ " ORDER by key ASC"
			+ " LIMIT 5")
	public List<ModelVo> getData(int key, String minDate); 
}
  • Model.java
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class ModelVo implements Serializable{
	private Integer key;
	private String refer;
}
  • Service.java
List<ModelVo> dataVo = rankNewsMapper.getData(data.getKey(), 날짜형식 입력);
  • application.properties
quarkus.native.additional-build-args=-H:ReflectionConfigurationFiles=reflection-config.json
  • reflection-config.json
[
  {
    "name" : "com.test.ModelVo",
    "allDeclaredConstructors" : true,
    "allPublicConstructors" : true,
    "allDeclaredMethods" : true,
    "allPublicMethods" : true,
    "allDeclaredFields" : true,
    "allPublicFields" : true
  }
]
profile
개발자, 아키텍트

0개의 댓글