Spring 在我的本地存储库中找不到云合同存根
Spring cloud contract stubs not found in my local repo
使用 Spring Cloud Contract 1.0.2.RELEASE,我可以在本地 Maven 存储库中发布存根,但是当我 运行 测试。
看起来在消费者方面,它为本地 maven 回购选择了一个与生产者不同的位置:尽管 Spring Cloud Contract 和 Aether 库进行了良好的记录,但我花了一段时间才弄清楚它出来,因为我用于本地 Maven 存储库的位置与默认位置相似(但不同)。
我正在使用 Maven 3.3.1。
在 org.springframework.cloud.contract.stubrunner.AetherFactories 中,我们清楚地看到它获取本地存储库位置是这样的:
private static final String MAVEN_LOCAL_REPOSITORY_LOCATION = "maven.repo.local";
private static String localRepositoryDirectory() {
return System.getProperty(MAVEN_LOCAL_REPOSITORY_LOCATION, System.getProperty("user.home") + "/.m2/repository");
}
因此,如果您使用类似这样的方法覆盖 Maven settings.xml 中的本地 Maven 存储库位置:
<localRepository>C:/HOMEWARE/maven_local_repo</localRepository>
您的生产者将在该位置安装存根,但消费者将在默认位置查找本地存储库,除非您通过 "maven.repo.local" 系统定义自己的位置 属性。
您可以在消费者端使用 surefire 这样做:
<build>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<maven.repo.local>${settings.localRepository}</maven.repo.local>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
使用 Spring Cloud Contract 1.0.2.RELEASE,我可以在本地 Maven 存储库中发布存根,但是当我 运行 测试。
看起来在消费者方面,它为本地 maven 回购选择了一个与生产者不同的位置:尽管 Spring Cloud Contract 和 Aether 库进行了良好的记录,但我花了一段时间才弄清楚它出来,因为我用于本地 Maven 存储库的位置与默认位置相似(但不同)。
我正在使用 Maven 3.3.1。
在 org.springframework.cloud.contract.stubrunner.AetherFactories 中,我们清楚地看到它获取本地存储库位置是这样的:
private static final String MAVEN_LOCAL_REPOSITORY_LOCATION = "maven.repo.local";
private static String localRepositoryDirectory() {
return System.getProperty(MAVEN_LOCAL_REPOSITORY_LOCATION, System.getProperty("user.home") + "/.m2/repository");
}
因此,如果您使用类似这样的方法覆盖 Maven settings.xml 中的本地 Maven 存储库位置:
<localRepository>C:/HOMEWARE/maven_local_repo</localRepository>
您的生产者将在该位置安装存根,但消费者将在默认位置查找本地存储库,除非您通过 "maven.repo.local" 系统定义自己的位置 属性。
您可以在消费者端使用 surefire 这样做:
<build>
...
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<maven.repo.local>${settings.localRepository}</maven.repo.local>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>