最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

mybatis自動(dòng)建表的實(shí)現(xiàn)方法

 更新時(shí)間:2020年11月02日 14:42:00   作者:深藍(lán)格調(diào)_  
這篇文章主要介紹了mybatis自動(dòng)建表的實(shí)現(xiàn)方法,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧

1.添加ACTable依賴(lài)

   <!--mybatis-plus自動(dòng)建表-->
    <dependency>
      <groupId>com.gitee.sunchenbin.mybatis.actable</groupId>
      <artifactId>mybatis-enhance-actable</artifactId>
      <version>1.1.1.RELEASE</version>
    </dependency>

2.配置(在此需要注意配置的路徑部分需要改成自己項(xiàng)目路徑)

   <!--mybatis-plus自動(dòng)建表-->
    <dependency>
      <groupId>com.gitee.sunchenbin.mybatis.actable</groupId>
      <artifactId>mybatis-enhance-actable</artifactId>
      <version>1.1.1.RELEASE</version>
    </dependency>

3.添加配置類(lèi)

package com.jpxx.clsh.autoconfig;

import com.alibaba.druid.pool.DruidDataSource;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.beans.factory.config.PropertiesFactoryBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

/**
 * @ClassName TestConfig
 * @Description
 * @Author Administrator
 * @Date 2020/11/2 0002 11:30
 * @Version 1.0
 */
@Configuration
@ComponentScan(basePackages = {"com.gitee.sunchenbin.mybatis.actable.manager.*"})
public class DataSourceConfig{

  //此處的路徑按照yml或properties文件路徑
  @Value("${jpxx.datasource.druid.driverClassName}")
  private String driver;

  @Value("${jpxx.datasource.druid.url}")
  private String url;

  @Value("${jpxx.datasource.druid.username}")
  private String username;

  @Value("${jpxx.datasource.druid.password}")
  private String password;

  @Bean
  public PropertiesFactoryBean configProperties() throws Exception{
    PropertiesFactoryBean propertiesFactoryBean = new PropertiesFactoryBean();
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    propertiesFactoryBean.setLocations(resolver.getResources("classpath*:application.yml"));
    return propertiesFactoryBean;
  }

  @Bean
  public DruidDataSource dataSource() {
    DruidDataSource dataSource = new DruidDataSource();
    dataSource.setDriverClassName(driver);
    dataSource.setUrl(url);
    dataSource.setUsername(username);
    dataSource.setPassword(password);
    dataSource.setMaxActive(30);
    dataSource.setInitialSize(10);
    dataSource.setValidationQuery("SELECT 1");
    dataSource.setTestOnBorrow(true);
    return dataSource;
  }

  @Bean
  public DataSourceTransactionManager dataSourceTransactionManager() {
    DataSourceTransactionManager dataSourceTransactionManager = new DataSourceTransactionManager();
    dataSourceTransactionManager.setDataSource(dataSource());
    return dataSourceTransactionManager;
  }

  @Bean
  public SqlSessionFactoryBean sqlSessionFactory() throws Exception{
    SqlSessionFactoryBean sqlSessionFactoryBean = new SqlSessionFactoryBean();
    sqlSessionFactoryBean.setDataSource(dataSource());
    PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
    sqlSessionFactoryBean.setMapperLocations(resolver.getResources("classpath*:com/gitee/sunchenbin/mybatis/actable/mapping/*/*.xml"));
    sqlSessionFactoryBean.setTypeAliasesPackage("com.jpxx.clsh.entity.*");
    return sqlSessionFactoryBean;
  }

}
package com.jpxx.clsh.autoconfig;

/**
 * @ClassName MyBatisMapperScannerConfig
 * @Description
 * @Author Administrator
 * @Date 2020/11/2 0002 10:15
 * @Version 1.0
 */
import org.mybatis.spring.mapper.MapperScannerConfigurer;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@AutoConfigureAfter(DataSourceConfig.class)
public class MyBatisMapperScannerConfig {

  @Bean
  public MapperScannerConfigurer mapperScannerConfigurer() throws Exception{
    MapperScannerConfigurer mapperScannerConfigurer = new MapperScannerConfigurer();
    mapperScannerConfigurer.setBasePackage("com.jpxx.clsh.dao.*;com.gitee.sunchenbin.mybatis.actable.dao.*");
    mapperScannerConfigurer.setSqlSessionFactoryBeanName("sqlSessionFactory");
    return mapperScannerConfigurer;
  }

}

4.實(shí)體類(lèi)

package com.jpxx.clsh.entity;

import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;



/**
 * @ClassName Test
 * @Description
 * @Author Administrator
 * @Date 2020/10/30 0030 16:48
 * @Version 1.0
 */

@Data
@Table(name = "aaaaaaaaaaaaaa")
public class Test {


  @Column(name = "role_id", type = MySqlTypeConstant.INT, isNull = false,isKey = true, isAutoIncrement = true, comment = "自增id")
  private Long id;

  @Column(name = "name", type = MySqlTypeConstant.VARCHAR, isNull = false, length = 20, comment = "角色名字")
  private String name;

  @Column(name = "name_zh", type = MySqlTypeConstant.VARCHAR, isNull = true, length = 20, comment = "角色的中文名字")
  private String name_zh;
}

運(yùn)行日志

到此這篇關(guān)于mybatis自動(dòng)建表的實(shí)現(xiàn)方法的文章就介紹到這了,更多相關(guān)mybatis 自動(dòng)建表內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Spring責(zé)任鏈模式使用實(shí)例講解

    Spring責(zé)任鏈模式使用實(shí)例講解

    責(zé)任鏈?zhǔn)切袨樾驮O(shè)計(jì)模式的一種,通過(guò)前一個(gè)處理者記錄下一個(gè)處理者的方式形成一條處理鏈。客戶(hù)端在調(diào)用時(shí)只需要將請(qǐng)求傳遞到責(zé)任上即可,無(wú)需關(guān)注鏈路中的具體的傳遞過(guò)程。而鏈路中內(nèi)部的處理,是按照前一個(gè)處理者記錄的下一個(gè)處理者依次執(zhí)行
    2023-01-01
  • Java中@DateTimeFormat和@JsonFormat注解介紹

    Java中@DateTimeFormat和@JsonFormat注解介紹

    @DateTimeFormat和@JsonFormat都是處理時(shí)間格式化問(wèn)題的,把其他類(lèi)型轉(zhuǎn)換成自己需要的時(shí)間類(lèi)型,下面這篇文章主要給大家介紹了關(guān)于Java中@DateTimeFormat和@JsonFormat注解介紹的相關(guān)資料,需要的朋友可以參考下
    2022-11-11
  • Java加密 消息摘要算法SHA實(shí)現(xiàn)詳解

    Java加密 消息摘要算法SHA實(shí)現(xiàn)詳解

    這篇文章主要介紹了Java加密 消息摘要算法SHA實(shí)現(xiàn)詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2019-07-07
  • 如何用Java?幾分鐘處理完?30?億個(gè)數(shù)據(jù)(項(xiàng)目難題)

    如何用Java?幾分鐘處理完?30?億個(gè)數(shù)據(jù)(項(xiàng)目難題)

    現(xiàn)有一個(gè) 10G 文件的數(shù)據(jù),里面包含了 18-70 之間的整數(shù),分別表示 18-70 歲的人群數(shù)量統(tǒng)計(jì),今天小編通過(guò)本文給大家講解如何用Java?幾分鐘處理完?30?億個(gè)數(shù)據(jù),這個(gè)問(wèn)題一直以來(lái)是項(xiàng)目難題,今天通過(guò)本文給大家詳細(xì)介紹下,感興趣的朋友一起看看吧
    2022-07-07
  • Springboot處理異常的常見(jiàn)方式

    Springboot處理異常的常見(jiàn)方式

    SpringBoot框架異常處理有多種處理方式,今天就帶大家了解一下常見(jiàn)的springboot異常處理方式,文中有非常詳細(xì)的介紹及代碼示例,需要的朋友可以參考下
    2021-06-06
  • Java中快速把map轉(zhuǎn)成json格式的方法

    Java中快速把map轉(zhuǎn)成json格式的方法

    這篇文章主要介紹了Java中快速把map轉(zhuǎn)成json格式的方法,本文使用json-lib.jar中的JSONSerializer.toJSON方法實(shí)現(xiàn)快速把map轉(zhuǎn)換成json,需要的朋友可以參考下
    2015-07-07
  • 基于Beanutils.copyProperties()的用法及重寫(xiě)提高效率

    基于Beanutils.copyProperties()的用法及重寫(xiě)提高效率

    這篇文章主要介紹了Beanutils.copyProperties( )的用法及重寫(xiě)提高效率的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-09-09
  • Java舉例講解分治算法思想

    Java舉例講解分治算法思想

    分治算法的基本思想是將一個(gè)規(guī)模為N的問(wèn)題分解為K個(gè)規(guī)模較小的子問(wèn)題,這些子問(wèn)題相互獨(dú)立且與原問(wèn)題性質(zhì)相同。求出子問(wèn)題的解,就可得到原問(wèn)題的解,本篇文章我們就用分治算法來(lái)實(shí)現(xiàn)歸并排序快速排序以及二分搜索算法
    2022-04-04
  • Java中的枚舉enum詳細(xì)解讀

    Java中的枚舉enum詳細(xì)解讀

    這篇文章主要介紹了Java中的枚舉enum詳細(xì)解讀,當(dāng)我們使用enum關(guān)鍵字開(kāi)發(fā)一個(gè)枚舉類(lèi)時(shí),默認(rèn)會(huì)繼承Enum類(lèi),而且是一個(gè)final類(lèi),當(dāng)有多個(gè)枚舉對(duì)象時(shí),使用逗號(hào) ,隔開(kāi),最后一個(gè)用分號(hào);結(jié)尾,需要的朋友可以參考下
    2024-01-01
  • Java注解中@Component和@Bean的區(qū)別

    Java注解中@Component和@Bean的區(qū)別

    這篇文章主要介紹了@Component和@Bean的區(qū)別,在這給大家簡(jiǎn)單介紹下作用對(duì)象不同:@Component 注解作用于類(lèi),而 @Bean 注解作用于方法,具體實(shí)例代碼參考下本文
    2024-03-03

最新評(píng)論

南宁市| 辉南县| 和平县| 泸定县| 襄汾县| 威远县| 沧源| 奉新县| 鸡东县| 襄城县| 大城县| 曲阜市| 汕头市| 荥阳市| 卢氏县| 资溪县| 运城市| 固镇县| 文山县| 惠来县| 泰顺县| 恭城| 太白县| 韶关市| 准格尔旗| 鸡泽县| 馆陶县| 湘潭县| 肃宁县| 襄樊市| 府谷县| 五大连池市| 儋州市| 韩城市| 迁西县| 新乡县| 普宁市| 普安县| 镇原县| 迁安市| 乐安县|