java Microstream与micronaut应用程序不工作

myss37ts  于 2023-06-20  发布在  Java
关注(0)|答案(2)|浏览(131)

创建了一个全新的micronaut应用程序,具有以下依赖项

dependencies {
    annotationProcessor("io.micronaut:micronaut-http-validation")
    annotationProcessor("io.micronaut.microstream:micronaut-microstream-annotations")
    implementation("io.micronaut:micronaut-http-client")
    implementation("io.micronaut:micronaut-jackson-databind")
    implementation("io.micronaut.microstream:micronaut-microstream")
    implementation("io.micronaut.microstream:micronaut-microstream-annotations")
    implementation("jakarta.annotation:jakarta.annotation-api")
    runtimeOnly("ch.qos.logback:logback-classic")
    developmentOnly("io.micronaut.microstream:micronaut-microstream-rest")
    annotationProcessor("io.micronaut.security:micronaut-security-annotations")
    implementation("io.micronaut.security:micronaut-security")
}

创建一个类如下

public class Fruit {
    @NonNull
    @NotBlank
    private final String name;

    @Nullable
    private String description;

    public Fruit(@NonNull String name,
                 @Nullable String description) {
        this.name = name;
        this.description = description;
    }

    @NonNull
    public String getName() {
        return name;
    }

    @Nullable
    public String getDescription() {
        return description;
    }

    public void setDescription(@Nullable String description) {
        this.description = description;
    }
}

application.yml文件

micronaut:
  application:
    name: demo
  security:
    intercept-url-map:
      - pattern: /microstream/**
        http-method: GET
        access:
          - isAnonymous()
netty:
  default:
    allocator:
      max-order: 3


microstream:
  storage:
    main:
      root-class: 'com.example.FruitContainer'
      storage-directory: 'build/fruit-storage'

参考-https://guides.micronaut.io/latest/micronaut-microstream-persistence-gradle-java.html
运行应用程序时,未创建存储目录build/fruit-storage
即使使用microstream UI,客户端也无法访问microstream REST端点

micronautVersion=3.9.3

GIT-回购-https://github.com/anandjaisy/microstream-micronaut

yzuktlbb

yzuktlbb1#

您的配置中包含错误的Root类。
https://github.com/anandjaisy/microstream-micronaut/blob/main/src/main/resources/application.yml#L20
你有com.example.Fruit,但我相信你想使用容器类。

bq8i3lrv

bq8i3lrv2#

GitHub Repo中的代码没有存储任何东西。
MicroStream引擎支持两种通用存储策略:懒惰和渴望储存。默认情况下,MicroStream使用延迟存储策略。
参见:https://docs.microstream.one/manual/storage/storing-data/lazy-eager-full.html

相关问题