契约文件上传到契约代理失败

Pact File upload to pact broker failing

将协议文件上传到协议代理时出现 "Failed to read pacts: NullPointerException" 问题。下面是我的堆栈跟踪和 POM 文件详细信息。 请帮忙。 下面是我的堆栈跟踪

  [INFO] loading pacts from target/pacts
[INFO] found pact file: PRODUCT-CART.json
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.476 s
[INFO] Finished at: 2017-10-03T15:09:20+08:00
[INFO] Final Memory: 11M/243M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.github.warmuuh:pactbroker-maven-plugin:0.0.9:upload-pacts (default-cli) on project Auth_Api_Consumer: Failed to read pacts: NullPointerException -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal com.github.warmuuh:pactbroker-maven-plugin:0.0.9:upload-pacts (default-cli) on project Auth_Api_Consumer: Failed to read pacts
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:212)
    at 

下面是我的POM.xml

                <plugin>
                    <groupId>com.github.warmuuh</groupId>
                    <artifactId>pactbroker-maven-plugin</artifactId>
                    <version>0.0.9</version>
                    <executions>
                    <!--CONSUMER Upload Pact File Starts -->    
                        <execution>
                          <id>upload-pacts</id>
                          <phase>test</phase>
                          <goals><goal>upload-pacts</goal></goals>
                          <configuration>
                           <brokerUrl>http://localhost:8080/</brokerUrl>
                           <!-- <brokerUrl>git@scm.hue.workslan:tools/hue-contract-testing.git</brokerUrl> -->
                            <pacts>${project.build.directory}/pacts</pacts>
                          </configuration>
                        </execution>
                    <!--CONSUMER Upload Pact File Ends -->
                        </executions>
                </plugin>

如果发生以下情况之一,就会出现此问题: 1) 您正在上传的 json 个文件中的 Consumer/Provider 个名称存在命名冲突。 解决方案:确保名称唯一,匹配规则不仅与子串匹配有关,还与catch "similar name"有关。请查看Broker匹配代码以获取更多详细信息。目前还没有这方面的文档。 示例:Cart_service 和 order_service 是不允许的,Car-order,order-processing 是不允许的,因为它们有共同的词。

2) 运行 如果有任何问题,mvn upload-pacts 将 return NullPointerException。要查看真正的错误,请确保改为 运行 mvn test 或 mvn install。它将向您显示确切的服务器响应状态代码。

有关名称相似的服务的发布协议,请参阅此文档:

发布契约时409

正常发布契约时(通过 PUT 到 /pacts/provider/PROVIDER/consumer/CONSUMER/version/CONSUMER_APP_VERSION),会自动创建 consumerproviderconsumer version 资源。

为了防止参与者(消费者或提供者)被多次创建,名称变体略有不同(例如 FooBar/foo-bar/foo bar/Foo Bar Service),如果新的参与者名称被认为足够类似于现有名称,将返回 409。响应正文将包含说明,如果参与者名称是现有的,则应更正参与者名称,或者如果参与者是新参与者,则应手动创建参与者。

不幸的是,某些 Pact Broker 客户端在发生这种情况时不会显示完整的错误文本。全文如下: This is the first time a pact has been published for "%{new_name}". The name "%{new_name}" is very similar to the following existing consumers/providers: %{existing_names} If you meant to specify one of the above names, please correct the pact configuration, and re-publish the pact. If the pact is intended to be for a new consumer or provider, please manually create "%{new_name}" using the following command, and then re-publish the pact: $ curl -v -XPOST -H "Content-Type: application/json" -d '{"name": "%{new_name}"}' http://broker/pacticipants If the pact broker requires authentication, include '-u <username>:<password>' in the command.

https://github.com/pact-foundation/pact_broker/wiki/Troubleshooting#409-when-publishing-a-pact