• springboot,jpa 添加全文索引


     springboot支持mysql5.7版本以上根据注解创建全文索引
    使用方法:
     1.拉取代码到本地工作空间  
       git clone https://gitee.com/light-zhang/springboot-fulltext.git 
     2.项目中引入依赖  
     <dependency>
        <groupId>skdapp.cn</groupId>
        <artifactId>springboot.fulltext</artifactId>
        <version>0.0.1</version> 
      </dependency>     
    3.在项目中使用  
    //启动类注入(scanPackages你的om扫描路径)
    @SpringbootFulltext(scanPackages = { "skdapp.cn.xxx.entity" })
    @SpringBootApplication(scanBasePackages = { "skdapp.cn.xxx.xxx" })
    public class Application {
        public static void main(String[] args) {
            SpringApplication.run(Application.class, args);
        }
    } 
    
    4.实体类使用 
    @Entity
    @Table(name = "demo")
    public class Demo implements Serializable {
        @Id
        @GeneratedValue(generator = "uuid")
        @GenericGenerator(name = "uuid", strategy = "uuid")
        @Column(name = "pk_id", nullable = false, unique = true, length = 32, columnDefinition = "varchar(32) COMMENT '主键ID,生成32位随机字符串' ")
        private String pkId;
    
        @MysqlFulltext(columnName = "content")
        @Column(name = "content", columnDefinition = "text COMMENT '内容' ")
        private String content;
    } 
    
    启动项目时,就可以根据Fulltext注解的配置自动扫描创建全文索引了 
    @MysqlFulltext默认生成全文索引策略table名称_column列名_idx,
        如果@MysqlFulltext使用了属性indexesName则按照indexesName的名称为全文索引命名
  • 相关阅读:
    项目实现多数据库支持 规格严格
    KeyTool 4096 RSA JDK1.5 1.4 规格严格
    KeyTool用法 规格严格
    Tomcat ssl配置 规格严格
    redmine install 规格严格
    zlib1.2.5的编译 规格严格
    Class unload 规格严格
    Ubuntu 8.10 “Intrepid Ibex” 发布时间表确定
    22项Windows或Mac不能而Linux可以的事
    英语谚语
  • 原文地址:https://www.cnblogs.com/light-zhang/p/10653991.html
Copyright © 2020-2023  润新知