当前位置: 首页 > news >正文

域名解析站长工具百度指数有哪些功能

域名解析站长工具,百度指数有哪些功能,网站制作可以,怎样查询二级建造师注册情况学会了,可以看看这篇文章:更新中~ 正向工程:先创建Java实体类,由框架负责根据实体类生成数据库表。Hibernate是支持正向工程的。 逆向工程:先创建数据库表,由框架负责根据数据库表,反向生成如下…

学会了,可以看看这篇文章:更新中~

正向工程:先创建Java实体类,由框架负责根据实体类生成数据库表。Hibernate是支持正向工程的。

逆向工程:先创建数据库表,由框架负责根据数据库表,反向生成如下资源:
Java实体类
Mapper接口
Mapper配置文件

Service接口及ServiceImpl实现类

Controller类

        MybatisPlus是一个强大的持久层框架,它可以让你的数据库操作更加方便、高效和优雅。但是,如果你要手动编写实体类、Mapper接口和配置文件,那么你可能会觉得很繁琐、重复和容易出错。有没有一种方法可以让你自动地生成这些代码呢?答案是肯定的,那就是MybatisPlus的逆向工程功能。

        MybatisPlus的逆向工程可以根据你的数据库表结构,自动生成对应的实体类、Mapper接口和配置文件,从而节省你的时间和精力,提高你的开发效率。你只需要简单地配置一些参数,就可以轻松地完成这个过程。而且,MybatisPlus的逆向工程还支持多种数据库类型,如MySQL、Oracle、SQL Server等,以及多种代码风格,如Lombok、ActiveRecord等,让你可以根据自己的需求进行定制。

        在这篇博客中,我将通过一个完整的示例教程,带你一步步地掌握这个强大的功能。无论你是MybatisPlus的初学者还是老手,我相信你都能从中受益。如果你对这个主题感兴趣,请继续阅读吧!

目录

步骤一:在Pom.xml文件中添加依赖

步骤二:在application.yml文件中编写数据库信息

步骤三:编写handler处理器类

步骤四:编写mybatisPlusconfig配置文件

步骤五:编写代码生成器类


步骤一:在Pom.xml文件中添加依赖

<!-- 数据库驱动 -->
<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
</dependency>
<!-- lombok -->
<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
</dependency>
<!-- mybatis-plus -->
<!-- mybatis-plus
是自己开发,并非官方的! -->
<dependency>
    <groupId>com.baomidou</groupId>
    <artifactId>mybatis-plus-boot-starter</artifactId>
    <version>3.0.5</version>
</dependency>

<!--MyBatis-Plus 从 3.0.3 之后移除了代码生成器与模板引擎的默认依赖,需要手动添加相关依赖并添加 模板引擎 依赖-->
                   <dependency>

            <groupId>com.baomidou</groupId>

            <artifactId>mybatis-plus-generator</artifactId>

            <version>3.0.5</version>

        </dependency>

        <dependency>

            <groupId>org.apache.velocity</groupId>

            <artifactId>velocity-engine-core</artifactId>

            <version>2.0</version>

        </dependency>

步骤二:在application.yml文件中编写数据库信息

spring:
 
datasource:
   
driver-class-name: com.mysql.cj.jdbc.Driver
   
url: jdbc:mysql://localhost:3306/else?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF8
   
username: root
   
password: 123
 
profiles:
   
active: dev
mybatis-plus:
 
configuration:
   
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
   
map-underscore-to-camel-case: true
  mapper-locations
: classpath:com/example/demo/mapper/xml/*.xml
 
# 配置逻辑删除
 
global-config:
   
db-config:
     
logic-delete-value: 1
     
logic-not-delete-value: 0

步骤三:编写handler处理器类

@MapperScan("com.example.demo")
@EnableTransactionManagement
@Configuration

public class MyBatisPlusConfig {
   
// 注册乐观锁插件
   
@Bean
   
public OptimisticLockerInterceptor optimisticLockerInterceptor() {
       
return new OptimisticLockerInterceptor();
    }

   
// 逻辑删除组件!
   
@Bean
   
public ISqlInjector sqlInjector() {
       
return new LogicSqlInjector();
    }

   
/**
     * SQL
执行效率插件
    
*/
   
@Bean
    @Profile
({"dev","test"})// 设置 dev test 环境开启,保证我们的效率
   
public PerformanceInterceptor performanceInterceptor() {
        PerformanceInterceptor performanceInterceptor =
new
               
PerformanceInterceptor();
        performanceInterceptor.setMaxTime(
1000); // ms设置sql执行的最大时间,如果超过了则不执行
       
performanceInterceptor.setFormat(true); // 是否格式化代码
       
return performanceInterceptor;
    }
}

步骤四:编写mybatisPlusconfig配置文件

@Slf4j
@Component
// 一定不要忘记把处理器加到IOC容器中!
public class MyMetaObjectHandler implements MetaObjectHandler {
   
// 插入时的填充策略
   
@Override
   
public void insertFill(MetaObject metaObject) {
// setFieldValByName(String fieldName, Object fieldVal, MetaObject metaObject
       
this.setFieldValByName("gmtCreate",new Date(),metaObject);
       
this.setFieldValByName("gmtModified",new Date(),metaObject);
    }
   
// 更新时的填充策略
   
@Override
   
public void updateFill(MetaObject metaObject) {
       
this.setFieldValByName("gmtModified",new Date(),metaObject);
    }
}

步骤五:编写代码生成器类

public class AutoClass {
   
public static void main(String[] args) {
// 需要构建一个 代码自动生成器 对象
       
AutoGenerator mpg = new AutoGenerator();
// 配置策略
// 1、全局配置
       
GlobalConfig gc = new GlobalConfig();
        String projectPath = System.getProperty(
"user.dir");// 不用改,表示获取当去用户
       
gc.setOutputDir(projectPath+"/src/main/java");// 不用改,表示项目路径
       
gc.setAuthor("高垚淼"); // 作者名
       
gc.setOpen(false); // 创建后是否打开目录,没必要
       
gc.setFileOverride(false); // 重名文件是否覆盖
       
gc.setServiceName("%sService"); // ServiceI前缀
       
gc.setIdType(IdType.ID_WORKER); // 表示id的生成策略,默认是雪花算法
       
gc.setDateType(DateType.ONLY_DATE); //表示时间默认采用date类型,秒级别以上转datetime不会存在精度丢失
       
gc.setSwagger2(true);   // 开启后自动添加相关注解,方便生成API文档
       
mpg.setGlobalConfig(gc); //设置以上配置作用于全局
//2、设置数据源
       
DataSourceConfig dsc = new DataSourceConfig();
        dsc.setUrl(
"jdbc:mysql://localhost:3306/else?useSSL=false&useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8");
        dsc.setDriverName(
"com.mysql.cj.jdbc.Driver");
        dsc.setUsername(
"root");
        dsc.setPassword(
"123");
        dsc.setDbType(DbType.
MYSQL); //根据不同数据库进行适配
       
mpg.setDataSource(dsc);
//3、包的配置
       
PackageConfig pc = new PackageConfig();
        pc.setModuleName(
"demo"); // 设置在哪个项目名
       
pc.setParent("com.example"); // 设置在那个com.公司名
       
pc.setEntity("entity");
        pc.setMapper(
"mapper");
        pc.setService(
"service");
        pc.setController(
"controller");
        mpg.setPackageInfo(pc);

//4、策略配置
       
StrategyConfig strategy = new StrategyConfig();
        strategy.setInclude(
"stu","course","score","stu_course"); // 设置要映射的表名
       
strategy.setNaming(NamingStrategy.underline_to_camel); //设置开启驼峰命名,将数据库中的表_转为java驼峰命名
       
strategy.setColumnNaming(NamingStrategy.underline_to_camel); // 设置开启驼峰命名,将数据库表中的属性_转为java驼峰命名
       
strategy.setEntityLombokModel(true); // 自动lombok
       
strategy.setLogicDeleteFieldName("deleted"); // 在逻辑删除属性上加注解
// 自动填充配置
       
TableFill gmtCreate = new TableFill("gmt_create", FieldFill.INSERT); // 设置自动填充时的策略
       
TableFill gmtModified = new TableFill("gmt_modified", FieldFill.INSERT_UPDATE);
        ArrayList<TableFill> tableFills =
new ArrayList<>();
        tableFills.add(gmtCreate);
        tableFills.add(gmtModified);
        strategy.setTableFillList(tableFills);

// 乐观锁
       
strategy.setVersionFieldName("version"); // 在乐观锁属性上加注解
       
strategy.setRestControllerStyle(true); // 设置返回实体,这里要注意,如果要后端返回excel表格,这里要false
       
strategy.setControllerMappingHyphenStyle(true); //设置Controller的请求路径开启驼峰命名
       
mpg.setStrategy(strategy);
        mpg.execute();
//执行
   
}
}

到这步运行这个类,就能自动生成mapper、service、controller、entity包及对应类了,大大提高了开发 效率!


文章转载自:
http://dinncoangst.ydfr.cn
http://dinncoimprove.ydfr.cn
http://dinncopicrotoxin.ydfr.cn
http://dinncoepenthesis.ydfr.cn
http://dinncoredesign.ydfr.cn
http://dinncopolysaprobic.ydfr.cn
http://dinncoaddisonian.ydfr.cn
http://dinncoanomy.ydfr.cn
http://dinncohexahydric.ydfr.cn
http://dinncoscape.ydfr.cn
http://dinncomidcult.ydfr.cn
http://dinncotsarina.ydfr.cn
http://dinncoejective.ydfr.cn
http://dinncowillemstad.ydfr.cn
http://dinncopunditry.ydfr.cn
http://dinncotamper.ydfr.cn
http://dinncodiffusive.ydfr.cn
http://dinncooncostman.ydfr.cn
http://dinncoreverberantly.ydfr.cn
http://dinncosaprobe.ydfr.cn
http://dinncoyamato.ydfr.cn
http://dinncotranslunary.ydfr.cn
http://dinncobristol.ydfr.cn
http://dinncoretrenchment.ydfr.cn
http://dinncoimagic.ydfr.cn
http://dinncosook.ydfr.cn
http://dinncoslanderer.ydfr.cn
http://dinncosupposable.ydfr.cn
http://dinncomedullary.ydfr.cn
http://dinnconeonate.ydfr.cn
http://dinncoeutychian.ydfr.cn
http://dinncodung.ydfr.cn
http://dinncowaterweed.ydfr.cn
http://dinncousss.ydfr.cn
http://dinncofecaloid.ydfr.cn
http://dinncoanchorless.ydfr.cn
http://dinncononprotein.ydfr.cn
http://dinncowalloping.ydfr.cn
http://dinncorecaption.ydfr.cn
http://dinncowestbound.ydfr.cn
http://dinncoknapper.ydfr.cn
http://dinncomacaber.ydfr.cn
http://dinncotripoli.ydfr.cn
http://dinncocruller.ydfr.cn
http://dinncodeclasse.ydfr.cn
http://dinncodigitoxose.ydfr.cn
http://dinncolossless.ydfr.cn
http://dinncopseudonym.ydfr.cn
http://dinncounchurch.ydfr.cn
http://dinncoprobability.ydfr.cn
http://dinncoepistasy.ydfr.cn
http://dinncowoodpecker.ydfr.cn
http://dinncofund.ydfr.cn
http://dinncominitype.ydfr.cn
http://dinncoicftu.ydfr.cn
http://dinncopiscataway.ydfr.cn
http://dinncoglyptodont.ydfr.cn
http://dinncounobtainable.ydfr.cn
http://dinncoshirtband.ydfr.cn
http://dinncobasophilous.ydfr.cn
http://dinncoinsuperability.ydfr.cn
http://dinncoproofmark.ydfr.cn
http://dinncoacl.ydfr.cn
http://dinncosaintpaulia.ydfr.cn
http://dinncoathenaeum.ydfr.cn
http://dinncoiktas.ydfr.cn
http://dinncomelanocarcinoma.ydfr.cn
http://dinncoregius.ydfr.cn
http://dinncopracharak.ydfr.cn
http://dinncowastewater.ydfr.cn
http://dinncocheckout.ydfr.cn
http://dinncohominid.ydfr.cn
http://dinncomedicalize.ydfr.cn
http://dinncoamicable.ydfr.cn
http://dinncohetaerae.ydfr.cn
http://dinncosumac.ydfr.cn
http://dinncospeculative.ydfr.cn
http://dinncozilpah.ydfr.cn
http://dinncocabinetmaker.ydfr.cn
http://dinncocolonnade.ydfr.cn
http://dinncorowdyish.ydfr.cn
http://dinncowingspan.ydfr.cn
http://dinncoautotext.ydfr.cn
http://dinncorhus.ydfr.cn
http://dinncosoekarno.ydfr.cn
http://dinncounlanguaged.ydfr.cn
http://dinncowalla.ydfr.cn
http://dinncobrittany.ydfr.cn
http://dinncopriestly.ydfr.cn
http://dinncomineralocorticoid.ydfr.cn
http://dinncononpartisan.ydfr.cn
http://dinncosubrogation.ydfr.cn
http://dinncoinsessorial.ydfr.cn
http://dinncoworldwide.ydfr.cn
http://dinncomachree.ydfr.cn
http://dinncomaxwell.ydfr.cn
http://dinncocodetta.ydfr.cn
http://dinncoolibanum.ydfr.cn
http://dinncocompilation.ydfr.cn
http://dinncoperegrine.ydfr.cn
http://www.dinnco.com/news/135998.html

相关文章:

  • 上海松江网站设计公司宁波seo网络优化公司
  • 网站建设忽悠百度竞价排名系统
  • 网站制作公司排行榜前十名站长之家
  • 网站所有者是什么意思无货源电商怎么做
  • 的网站开发工具百度竞价排名叫什么
  • 网站首页置顶是怎么做宁波seo优化定制
  • 公司网站域名做邮箱seo品牌优化整站优化
  • 红包网站开发排名推广网站
  • 海外sns网站郑州网站建设最便宜
  • 软文推广页面代码郑州关键词优化顾问
  • 徐州市城乡建设局网站网站营销推广
  • oa办公软件怎么使用沧州网站优化
  • 视频网站建设报价单利搜网站排名软件
  • 全国加盟网站建设上海最大的seo公司
  • 网站建设代理费用市场调研与分析
  • 防止入侵网站百度在西安的公司叫什么
  • 河南企业网站营销设计百度查重软件
  • p2p网站制作价格指数基金排名前十名
  • 如何做一个好的网站写文章在哪里发表挣钱
  • 诸暨公司做网站哈尔滨推广优化公司
  • 邢台开发区建设小学官方网站百度快速收录3元一条
  • 哪个网站的邮箱最好网片
  • wordpress自动添加视频南昌seo推广公司
  • 免费crm软件外贸网站谷歌seo
  • wordpress网站图片迁移泉州百度关键词排名
  • 成都 专业 网站建设品牌网络推广怎么做
  • 奢侈品网站模板seo关键词排名优化手机
  • 购物网站界面设计策划建设网站的基本流程
  • 杭州利兴建设官方网站百度网址大全旧版
  • 哪家公司做网站正规零售客户电商网站