1. Mybatis 프레임워크
1. mybatis 소개
MyBatis는 맞춤형 SQL, 저장 프로시저 및 고급 매핑을 지원하는 뛰어난 지속성 계층 프레임워크입니다. MyBatis는 거의 모든 JDBC 코드와 매개변수 수동 설정 및 결과 세트 검색을 방지합니다. MyBatis는 간단한 XML 또는 주석을 사용하여 기본 유형, 인터페이스 및 Java POJO(Plain Old Java Objects, Plain Old Java Object)를 구성하고 데이터베이스의 레코드에 매핑할 수 있습니다.
2. Mybatis 기능
1)sql语句与代码分离,存放于xml配置文件中,方便管理 2)用逻辑标签控制动态SQL的拼接,灵活方便 3)查询的结果集与java对象自动映射 4)编写原生态SQL,接近JDBC 5)简单的持久化框架,框架不臃肿简单易学
3. 적용 가능한 시나리오
MyBatis는 SQL 자체에 중점을 두고 있으며 충분히 유연한 DAO 레이어 솔루션입니다.
MyBatis는 높은 성능 요구 사항이 있거나 변화하는 요구 사항이 있는 프로젝트에 적합한 선택이 될 것입니다.
2. SpringBoot2와의 통합
1. 프로젝트 구조 다이어그램
이 연결 풀은 druid 연결 풀을 사용합니다.
2. 핵심 종속성
<!-- mybatis依赖 --> <dependency> <groupid>org.mybatis.spring.boot</groupid> <artifactid>mybatis-spring-boot-starter</artifactid> <version>1.3.2</version> </dependency> <!-- mybatis的分页插件 --> <dependency> <groupid>com.github.pagehelper</groupid> <artifactid>pagehelper</artifactid> <version>4.1.6</version> </dependency>
3. 핵심 구성
mybatis: # mybatis配置文件所在路径 config-location: classpath:mybatis.cfg.xml type-aliases-package: com.boot.mybatis.entity # mapper映射文件 mapper-locations: classpath:mapper/*.xml
4. 리버스 엔지니어링으로 생성된 파일
코드는 여기에 게시되지 않습니다.
5. 기본 테스트 인터페이스 작성
// 增加 int insert(ImgInfo record); // 组合查询 List<img info alt="SpringBoot2에 Mybatis 프레임워크를 통합하는 방법" > selectByExample(ImgInfoExample example); // 修改 int updateByPrimaryKeySelective(ImgInfo record); // 删除 int deleteByPrimaryKey(Integer imgId);</imginfo>
7. 컨트롤 레이어 테스트 클래스
@Service public class ImgInfoServiceImpl implements ImgInfoService { @Resource private ImgInfoMapper imgInfoMapper ; @Override public int insert(ImgInfo record) { return imgInfoMapper.insert(record); } @Override public List<img info alt="SpringBoot2에 Mybatis 프레임워크를 통합하는 방법" > selectByExample(ImgInfoExample example) { return imgInfoMapper.selectByExample(example); } @Override public int updateByPrimaryKeySelective(ImgInfo record) { return imgInfoMapper.updateByPrimaryKeySelective(record); } @Override public int deleteByPrimaryKey(Integer imgId) { return imgInfoMapper.deleteByPrimaryKey(imgId); } }</imginfo>
3. 페이징 플러그인 통합
1. @RestController
public class ImgInfoController {
@Resource
private ImgInfoService imgInfoService ;
// 增加
@RequestMapping("/insert")
public int insert(){
ImgInfo record = new ImgInfo() ;
record.setUploadUserId("A123");
record.setImgTitle("博文图片");
record.setSystemType(1) ;
record.setImgType(2);
record.setImgUrl("https://avatars0.githubusercontent.com/u/50793885?s=460&v=4");
record.setLinkUrl("https://avatars0.githubusercontent.com/u/50793885?s=460&v=4");
record.setShowState(1);
record.setCreateDate(new Date());
record.setUpdateDate(record.getCreateDate());
record.setRemark("知了");
record.setbEnable("1");
return imgInfoService.insert(record) ;
}
// 组合查询
@RequestMapping("/selectByExample")
public List<img info alt="SpringBoot2에 Mybatis 프레임워크를 통합하는 방법" > selectByExample(){
ImgInfoExample example = new ImgInfoExample() ;
example.createCriteria().andRemarkEqualTo("知了") ;
return imgInfoService.selectByExample(example);
}
// 修改
@RequestMapping("/updateByPrimaryKeySelective")
public int updateByPrimaryKeySelective(){
ImgInfo record = new ImgInfo() ;
record.setImgId(11);
record.setRemark("知了一笑");
return imgInfoService.updateByPrimaryKeySelective(record);
}
// 删除
@RequestMapping("/deleteByPrimaryKey")
public int deleteByPrimaryKey() {
Integer imgId = 11 ;
return imgInfoService.deleteByPrimaryKey(imgId);
}
}</imginfo>
2. 페이징 구현 코드http://localhost:8010/insert
http://localhost:8010/selectByExample
http://localhost:8010/updateByPrimaryKeySelective
http://localhost:8010/deleteByPrimaryKey
3. 테스트 인터페이스<?xml version="1.0" encoding="UTF-8" ?>
nbsp;configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<plugins>
<!--mybatis分页插件-->
<plugin>
<property></property>
</plugin>
</plugins>
</configuration>
위 내용은 SpringBoot2에 Mybatis 프레임워크를 통합하는 방법의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

javaremainsagoodlugageedueToitscontinuousevolutionandrobustecosystem.1) lambdaexpressionsenhancececeadeabilitys.2) Streamsallowforefficileddataprocessing, 특히 플레어로드 라트 웨이션

javaisgreatduetoitsplatform incendence, robustoopsupport, extensibraries 및 strongcommunity.1) platforminceptenceviajvmallowscodetorunonvariousplatforms.2) oopeatures inncapsulation, Nheritance, and Polymorphismenblularandscode.3)

Java의 5 가지 주요 특징은 다형성, Lambda Expressions, Streamsapi, 제네릭 및 예외 처리입니다. 1. 다형성을 사용하면 다른 클래스의 물체가 공통 기본 클래스의 물체로 사용될 수 있습니다. 2. Lambda 표현식은 코드를보다 간결하게 만듭니다. 특히 컬렉션 및 스트림을 처리하는 데 적합합니다. 3.StreamSapi는 대규모 데이터 세트를 효율적으로 처리하고 선언적 작업을 지원합니다. 4. 제네릭은 유형 안전 및 재사용 성을 제공하며 편집 중에 유형 오류가 잡히립니다. 5. 예외 처리는 오류를 우아하게 처리하고 신뢰할 수있는 소프트웨어를 작성하는 데 도움이됩니다.

java'stopfeaturessificeNificeLynitySteperformanceandscalibers

JVM의 핵심 구성 요소에는 클래스 로더, runtimedataarea 및 executionEngine이 포함됩니다. 1) 클래스 로더는 클래스 및 인터페이스로드, 연결 및 초기화를 담당합니다. 2) runtimedataarea에는 Methodarea, 힙, 스택, Pcregister 및 NativeMethodStacks가 포함되어 있습니다. 3) ExecutionEngine은 바이트 코드의 실행 및 최적화를 담당하는 통역사, JitCompiler 및 GarbageCollector로 구성됩니다.

Java'sSafetyandsecurityArebolsteredBy : 1) 강력한, reventStype relatedErrors; 2) AutomaticMemoryManagementViageGageCollection; 3) 샌드 박스, 고립 코드 프롬 시스템; 및 4) 강도 핸드 링, 보장

javaoffersseveralkeyfeaturestenhancecodingskills : 1) 객체 지향적 인 프로그래밍 allowsmodelingreal-worldentities, 예시적인 혈관 림 모르 즘 .2) 예외적 인 handlingprovidesrobusterrormanagement.3) LambdaexorsionssimplifyOperations, 개선

thejvmisacrucialcomponentsThrunsjavacodebacodebybacodebytranslatingitintintintincinomachine-specificinstructions, 영향력 성능, 보안 및 포트 가능성


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

Video Face Swap
완전히 무료인 AI 얼굴 교환 도구를 사용하여 모든 비디오의 얼굴을 쉽게 바꾸세요!

인기 기사

뜨거운 도구

WebStorm Mac 버전
유용한 JavaScript 개발 도구

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

mPDF
mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

PhpStorm 맥 버전
최신(2018.2.1) 전문 PHP 통합 개발 도구