使用schema-registry:download时出现问题



我从这里使用模式注册表下载maven https://docs.confluent.io/platform/current/schema-registry/develop/maven-plugin.html,但是我无法将模式下载到我的本地项目中。这是我的插件内容。

<plugin>
<groupId>io.confluent</groupId>
<artifactId>kafka-schema-registry-maven-plugin</artifactId>
<version>6.1.0</version>
<configuration>
<schemaRegistryUrls>
<param>http://localhost:8081</param>
</schemaRegistryUrls>
<outputDirectory>src/main/avro</outputDirectory>
<subjectPatterns>
<param>MysqlTest2.oms.locations-value</param>
</subjectPatterns>
<subjects/>
</configuration>
</plugin>

有人能帮忙吗?加载maven更改后,我应该单击"clean"one_answers"package"使其工作吗?非常感谢!!

首先,确保您有插件存储库

<pluginRepositories>
<pluginRepository> 
<id>confluent</id> 
<name>Confluent</name> 
<url>https://packages.confluent.io/maven/</url> 
</pluginRepository> 
</pluginRepositories>

然后,插件有多个目标,所以您需要指定要运行哪个,并且在编译之前绑定到Maven阶段不会有什么坏处

<plugin>
<groupId>io.confluent</groupId>
<artifactId>kafka-schema-registry-maven-plugin</artifactId>
<version>${confluent.version}</version>
<executions>
<execution>
<id>avro-resources</id>
<phase>process-resources</phase>
<goals>
<goal>download</goal>
</goals>
</execution>
</executions>
<configuration>
...
</configuration>

您应该在Maven构建中看到如下所示的输出

[INFO] --- kafka-schema-registry-maven-plugin:6.1.0:download (avro-resources) @ project ---
[INFO] Getting all subjects on schema registry...
[INFO] Schema Registry has XXX subject(s).
[INFO] Downloading latest metadata for mySubject-value.
[INFO] Writing schema for Subject(mySubject-value) to /project/src/main/avro/mySubject-value.avsc.

如果你需要得到一个特定的版本,然后查看Maven:从url下载文件,并使用/subjects/:name/versions/:number/schema端点

除了将下载目标附加到@OneCricketeer正确提到的maven阶段之外,您还可以像下面这样直接调用插件的下载目标:

mvn schema-registry:download

最新更新