国产亚洲精品福利在线无卡一,国产精久久一区二区三区,亚洲精品无码国模,精品久久久久久无码专区不卡

當前位置: 首頁 > news >正文

網(wǎng)站開發(fā)類標書報價明細表常用的網(wǎng)絡推廣方式有哪些

網(wǎng)站開發(fā)類標書報價明細表,常用的網(wǎng)絡推廣方式有哪些,中小企業(yè)新聞網(wǎng)站建設,個人網(wǎng)站的設計與實現(xiàn)的任務書框架介紹 MyBatis-Flex 是一個優(yōu)雅的 MyBatis 增強框架,它非常輕量、同時擁有極高的性能與靈活性。 MyBatis-Flex 官方文檔 說明 本文參照官方文檔的【快速開始】 章節(jié),編寫 Spring Boot 項目的代碼示例。 快速開始 創(chuàng)建數(shù)據(jù)庫表 直接參照官網(wǎng)示…

框架介紹

MyBatis-Flex 是一個優(yōu)雅的 MyBatis 增強框架,它非常輕量、同時擁有極高的性能與靈活性。

MyBatis-Flex 官方文檔
在這里插入圖片描述

說明

本文參照官方文檔的【快速開始】 章節(jié),編寫 Spring Boot 項目的代碼示例。

快速開始

創(chuàng)建數(shù)據(jù)庫表

直接參照官網(wǎng)示例,SQL如下:

CREATE TABLE IF NOT EXISTS `tb_account`
(`id`        INTEGER PRIMARY KEY auto_increment,`user_name` VARCHAR(100),`age`       INTEGER,`birthday`  DATETIME
);INSERT INTO tb_account(id, user_name, age, birthday)
VALUES (1, '張三', 18, '2020-01-11'),(2, '李四', 19, '2021-03-21');

依賴

MyBatis-Flex 核心依賴

        <dependency><groupId>com.mybatis-flex</groupId><artifactId>mybatis-flex-spring-boot-starter</artifactId><version>1.7.3</version></dependency><!-- 數(shù)據(jù)庫連接池依賴必須添加,否則會報錯 --><dependency><groupId>com.alibaba</groupId><artifactId>druid-spring-boot-starter</artifactId><version>1.2.20</version></dependency>

驅(qū)動依賴(MySQL)

        <dependency><groupId>com.mysql</groupId><artifactId>mysql-connector-j</artifactId><scope>runtime</scope></dependency>

其余依賴,比如 Lombok,spring-boot-starter-web,spring-boot-starter-test,此處省略。

數(shù)據(jù)源配置

application.yml 中添加數(shù)據(jù)源配置。

spring:datasource:url: jdbc:mysql://localhost:3306/mybatis-flexusername: rootpassword: passwordtype: com.alibaba.druid.pool.DruidDataSource

APT 配置

MyBatis-Flex APT 配置
MyBatis-Flex 使用了 APT(Annotation Processing Tool)技術,在項目編譯的時候,會自動根據(jù) Entity 類定義的字段幫你生成 “ACCOUNT” 類以及 Entity 對應的 Mapper 類, 通過開發(fā)工具構建項目(如下圖),或者執(zhí)行 maven 編譯命令: mvn clean package 都可以自動生成。這個原理和 lombok 一致。

要對 MyBatis-Flex 的 APT 細節(jié)選項進行配置,你需要在項目的 根目錄 ( pom.xml 所在的目錄)下創(chuàng)建名為 mybatis-flex.config 的文件。

配置文件:mybatis-flex.config

# 開啟 Mapper 自動生成
processor.mapper.generateEnable = true
# 開啟 @Mapper 注解
processor.mapper.annotation = true

配置文件圖片示例

在這里插入圖片描述

實體類和Mapper

實體類

這里使用了 Lombok 來簡化代碼。

package com.example.db.mybatisflex.entity;import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;/*** 賬戶 實體類。** @author 宋冠巡* @since 2023-10-29*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(value = "tb_account")
public class Account implements Serializable {@Id(keyType = KeyType.Auto)private Integer id;private String userName;private Integer age;private LocalDateTime birthday;}

Mapper

Mapper 使用APT技術,編譯之后自動生成,示例如下:
在這里插入圖片描述

測試

package com.example;import com.example.db.mybatisflex.entity.Account;
import com.example.db.mybatisflex.mapper.AccountMapper;
import com.mybatisflex.core.query.QueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;import static com.example.db.mybatisflex.entity.table.AccountTableDef.ACCOUNT;@Slf4j
@SpringBootTest
class MybatisFlexDemoApplicationTests {private final AccountMapper accountMapper;@Autowiredpublic MybatisFlexDemoApplicationTests(AccountMapper accountMapper) {this.accountMapper = accountMapper;}@Testvoid contextLoads() {QueryWrapper queryWrapper = QueryWrapper.create().select().where(ACCOUNT.AGE.eq(18));Account account = accountMapper.selectOneByQuery(queryWrapper);log.info("accounts = {}", account);}}

控制臺輸出:

accounts = Account(id=1, userName=張三, age=18, birthday=2020-01-11T00:00)

代碼生成器

使用 代碼生成器 ,根據(jù)數(shù)據(jù)庫逆向生成 實體類Service。
生成的位置:生成器類 所在目錄,作為根目錄。

依賴

        <!-- 代碼生成器 --><dependency><groupId>com.mybatis-flex</groupId><artifactId>mybatis-flex-codegen</artifactId><version>1.7.3</version></dependency><!-- 加入代碼生成器后,只有加入 processor 依賴,才能正常使用 APT。--><dependency><groupId>com.mybatis-flex</groupId><artifactId>mybatis-flex-processor</artifactId><version>1.7.3</version><scope>provided</scope></dependency>

代碼生成器 - 代碼

package com.example.db.mybatisflex;import com.alibaba.druid.pool.DruidDataSource;
import com.mybatisflex.codegen.Generator;
import com.mybatisflex.codegen.config.GlobalConfig;public class Codegen {public static void main(String[] args) {// 配置數(shù)據(jù)源DruidDataSource dataSource = new DruidDataSource();dataSource.setUrl("jdbc:mysql://localhost:3306/mybatis-flex");dataSource.setUsername("root");dataSource.setPassword("password");// 創(chuàng)建配置內(nèi)容GlobalConfig globalConfig = createGlobalConfigUseStyle1();// 通過 datasource 和 globalConfig 創(chuàng)建代碼生成器Generator generator = new Generator(dataSource, globalConfig);// 生成代碼generator.generate();}public static GlobalConfig createGlobalConfigUseStyle1() {// 創(chuàng)建配置內(nèi)容GlobalConfig globalConfig = new GlobalConfig();// 設置作者globalConfig.setAuthor("宋冠巡");// 設置根包globalConfig.setBasePackage("com.example.db.mybatisflex");// 設置表前綴和只生成哪些表globalConfig.setTablePrefix("tb_");globalConfig.setGenerateTable("tb_account");// 設置生成 entity 并啟用 LombokglobalConfig.setEntityGenerateEnable(true);globalConfig.setEntityWithLombok(true);// 設置生成 mapper :如果使用 APT 生成 mapper,則可以不用由代碼生成器來生成。// globalConfig.setMapperGenerateEnable(true);// 設置生成 serviceglobalConfig.setServiceGenerateEnable(true);globalConfig.setServiceImplGenerateEnable(true);return globalConfig;}}

生成效果

在這里插入圖片描述

SQL 日志打印

內(nèi)置方案

package com.example.db.config;import com.mybatisflex.core.audit.AuditManager;
import com.mybatisflex.core.audit.ConsoleMessageCollector;
import com.mybatisflex.core.audit.MessageCollector;
import org.springframework.context.annotation.Configuration;@Configuration
public class MyBatisFlexConfiguration {public MyBatisFlexConfiguration() {// 開啟審計功能AuditManager.setAuditEnable(true);// 設置 SQL 審計收集器MessageCollector collector = new ConsoleMessageCollector();AuditManager.setMessageCollector(collector);}}

MyBatis 自帶方案

application.yml 中添加配置。

mybatis-flex:configuration:# 打印SQL日志log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

Mapper 鏈式操作

package com.example;import com.example.db.mybatisflex.entity.Account;
import com.example.db.mybatisflex.mapper.AccountMapper;
import com.mybatisflex.core.query.QueryChain;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;import java.util.List;import static com.example.db.mybatisflex.entity.table.AccountTableDef.ACCOUNT;@Slf4j
@SpringBootTest
class ChainTest {private final AccountMapper accountMapper;@Autowiredpublic ChainTest(AccountMapper accountMapper) {this.accountMapper = accountMapper;}@Testvoid testChain() {List<Account> accounts = QueryChain.of(accountMapper).select(ACCOUNT.ALL_COLUMNS).from(ACCOUNT).where(ACCOUNT.AGE.ge(18)).list();log.info("accounts = {}", accounts);}}

在這里插入圖片描述

Service 鏈式操作

package com.example;import com.example.db.mybatisflex.entity.Account;
import com.example.db.mybatisflex.service.AccountService;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;import java.util.List;import static com.example.db.mybatisflex.entity.table.AccountTableDef.ACCOUNT;/*** 測試 Service*/
@Slf4j
@SpringBootTest
class ServiceTest {private final AccountService accountService;@Autowiredpublic ServiceTest(AccountService accountService) {this.accountService = accountService;}/*** 測試 Service 的 鏈式操作*/@Testvoid testServiceQueryChain() {List<Account> accounts = accountService.queryChain().select(ACCOUNT.ALL_COLUMNS).from(ACCOUNT).where(ACCOUNT.AGE.ge(18)).list();log.info("accounts = {}", accounts);}
}

在這里插入圖片描述

http://m.aloenet.com.cn/news/40097.html

相關文章:

  • 網(wǎng)站如何兼容ie6湛江今日頭條新聞
  • 建設網(wǎng)站的網(wǎng)站江蘇青島seo整站優(yōu)化
  • 戚墅堰常州做網(wǎng)站seo頁面優(yōu)化公司
  • 做刷贊網(wǎng)站能賺錢嗎sem競價推廣
  • 東莞營銷網(wǎng)站建設重慶seo建站
  • 網(wǎng)站上如何設置行間距西安官網(wǎng)seo技術
  • 涉縣企業(yè)做網(wǎng)站推廣西安關鍵字優(yōu)化哪家好
  • 做動態(tài)網(wǎng)站必學營銷型網(wǎng)站建設模板
  • 網(wǎng)站 錯誤代碼免費隱私網(wǎng)站推廣
  • 怎么建立掙流量的網(wǎng)站百度平臺客服人工電話
  • 紹興專業(yè)做網(wǎng)站的公司搜索引擎營銷方法主要有三種
  • 量化交易網(wǎng)站開發(fā)網(wǎng)站改版公司哪家好
  • 北京市建設工程審核網(wǎng)站十大經(jīng)典事件營銷案例分析
  • 寶盈集團直營網(wǎng)站怎么做seo推廣方案
  • 海寧公司做網(wǎng)站營銷策略國內(nèi)外文獻綜述
  • 怎么判斷網(wǎng)站是否被k百度登陸
  • 怎么用dw第一次做網(wǎng)站關鍵詞優(yōu)化步驟簡短
  • 網(wǎng)站設計中下拉列表怎么做如何刷關鍵詞指數(shù)
  • 自己怎么制作網(wǎng)站百度排行
  • 網(wǎng)站建設規(guī)劃設計書個人網(wǎng)站的制作模板
  • 重慶網(wǎng)站設計公司網(wǎng)站制作百度熱搜的含義
  • pta編程網(wǎng)站網(wǎng)絡服務商
  • 知果果網(wǎng)站誰做的網(wǎng)站建設費用多少錢
  • 深圳營銷型網(wǎng)站建設電話網(wǎng)站快速排名上
  • 做動態(tài)網(wǎng)站的軟件怎么自己制作網(wǎng)頁
  • 公司網(wǎng)站建設工作方案口碑營銷的特點
  • 網(wǎng)站內(nèi)怎么做鏈接站長查詢站長工具
  • 長沙高端網(wǎng)站制作公司上海b2b網(wǎng)絡推廣外包
  • 網(wǎng)站制作公透明清晰北京seo關鍵詞優(yōu)化外包
  • 廣州域名企業(yè)網(wǎng)站建站哪家好百度收錄網(wǎng)站需要多久