Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/mongodb/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/list/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring 未在mongoDB中使用@TextIndexed创建文本索引_Spring_Mongodb_Spring Data Jpa_Spring Data_Spring Data Mongodb - Fatal编程技术网

Spring 未在mongoDB中使用@TextIndexed创建文本索引

Spring 未在mongoDB中使用@TextIndexed创建文本索引,spring,mongodb,spring-data-jpa,spring-data,spring-data-mongodb,Spring,Mongodb,Spring Data Jpa,Spring Data,Spring Data Mongodb,我有下面的POJO课程 @Document("Product") @FieldNameConstants @NoArgsConstructor @Getter @Setter public class Product extends OptimisticLock<Integer>{ @Id private String id; @Field("name") @TextIndexed private Str

我有下面的POJO课程

@Document("Product")
@FieldNameConstants
@NoArgsConstructor
@Getter
@Setter
public class Product extends OptimisticLock<Integer>{
    @Id
    private String id;
    @Field("name")
    @TextIndexed
    private String name;
    @Field("price")
    private float price;
    @Field("description")
    @TextIndexed(weight = 2)
    private String description;

    public Product(String name, float price, String description) {
        this.name = name;
        this.price = price;
        this.description = description;
    }
}
此迁移使用默认值添加新记录,但不会创建索引。即使我通过禁用迁移来插入记录,它也不会创建索引

我做错的事找不到解决办法

我有以下依赖项

dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-rest'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    implementation 'org.springdoc:springdoc-openapi-ui:1.4.3'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    implementation 'org.springframework.cloud:spring-cloud-starter-config'
    implementation 'org.springframework.kafka:spring-kafka'
    implementation 'org.projectlombok:lombok'
    implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
}
在这里找到了答案
dependencies {
    implementation 'org.springframework.boot:spring-boot-starter-data-rest'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
    implementation 'org.springdoc:springdoc-openapi-ui:1.4.3'
    implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
    implementation 'org.springframework.boot:spring-boot-starter-actuator'
    developmentOnly 'org.springframework.boot:spring-boot-devtools'
    implementation 'org.springframework.cloud:spring-cloud-starter-config'
    implementation 'org.springframework.kafka:spring-kafka'
    implementation 'org.projectlombok:lombok'
    implementation 'org.springframework.boot:spring-boot-starter-data-mongodb'
}