在将pact文件上传到pact代理时,发出“未能读取契约: 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>发布于 2017-10-15 23:16:17
请参阅有关为具有类似名称的服务发布契约的文档:
409在发布协议时
当pact正常发布时(通过PUT to /pacts/provider/PROVIDER/consumer/CONSUMER/version/CONSUMER_APP_VERSION),consumer、provider和consumer version资源将自动创建。
为了防止使用稍微不同的名称变体(例如,用户或提供者)多次创建pacticipant (消费者或提供者)。( FooBar/foo- Bar /foo bar/Foo Bar服务),如果新的参与者名称被认为与现有名称非常相似,则将返回一个409。响应机构将包含指示,说明如果拟为现有名称,则应更正pacticipant名称;如果拟为新名称,则应手动创建该pacticipant名称。
不幸的是,当发生这种情况时,一些clients客户端没有显示完整的错误文本。全文如下: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.
发布于 2017-10-09 10:33:03
如果发生以下情况之一,就会出现此问题: 1)您要上载的json文件中的使用者/提供者名称中存在命名冲突。解决方案:确保名称是唯一的,匹配规则不仅与子字符串匹配相关,而且还捕获“相似名称”.Please检查代理匹配代码以获得更多详细信息。目前还没有这方面的文件。例如: Cart_service和order_service是不允许的,汽车订单和订单处理是不允许的,因为他们有共同的词汇.
2)如果有任何问题,运行mvn上传协议将返回NullPointerException。要查看真正的错误,请确保您运行的是mvn测试或mvn安装。它将显示准确的服务器响应状态代码。
https://stackoverflow.com/questions/46540758
复制相似问题