我和我的团队对 Java 方面的事情还很陌生。 我们创建了一个使用 spring 框架的新休息服务。 我们正在努力实现构建自动化。
我们有自己的存储库,我们想要去查找依赖项。 我们将所有第三方依赖项放入此存储库中,并希望构建在搜索依赖项时查看此存储库。
我们的 pom.xml 看起来像这样。
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>com.squareup.retrofit</groupId>
<artifactId>retrofit</artifactId>
<version>1.9.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>
对于这些 spring 依赖项,我们需要哪些 jar? 我如何找出我们的存储库中应该有哪些 jar 以便我们可以构建我们的项目?
最佳答案
您需要指定要在 pom 文件中使用的存储库。作为示例,我们使用 Nexus 存储库,其中放置了所需的其他 jar。它还充当中央存储库的缓存,因此我们不需要显式包含来自那里的所有 jar。
您的 pom.xml 文件中需要类似的内容:
<!-- location for other artifact uploads -->
<repositories>
<repository>
<id>YourRepositoryId</id>
<url>http://yourrepo.com/nexus/content/repositories/thirdparty/</url>
</repository>
</repositories>
那么您的构建自动化将需要一种指定用户和密码的方法。在常规 Maven 设置中,您将使用用户 settings.xml 文件并像这样填充它。不同的自动构建系统可能会以不同的方式执行此操作,因此您需要查看您的系统从哪里获取 Maven 设置。
<!-- This exists so that environments without a user can still access the repository. -->
<settings>
<servers>
<server>
<id>YourRepositoryId</id>
<username>yourUserName</username>
<password>yourPassword</password>
</server>
</servers>
</settings>
关于确定要使用的jar文件Maven Dependency Plugin是一个很好的工具,用于分析工作构建以查看其中包含的内容。
希望这对您有所帮助,但如果没有,请随时提出任何问题。
关于java - Maven/Spring 私有(private)存储库设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37260958/