2016-05-16 2 views
0

私と私のチームは、Java側でかなり新しいものです。 Spring Frameworkを使用した新しいレストサービスを作成しました。 ビルドを自動化しようとしています。Maven/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> 

これらの春の依存関係については、私たちに必要なものは何ですか? プロジェクトを構築するために、どの瓶をレポに含めるべきかを知るにはどうすればいいですか?

+0

いくつかのメイキングレポが必要な場合。 "ローカルキャッシュ"、あなたは工芸品のようなツールを見てください –

答えて

0

pomファイルで使用するリポジトリを指定する必要があります。例として、必要な他のjarファイルを置くNexusリポジトリを使用します。また、中央リポジトリに対してキャッシュとして機能するので、そこから来るすべての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設定を取得するのかを確認する必要があります。 Maven Dependency Pluginを使用するためにjarファイルを決定する点で

<!-- 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> 

が含まれているかを確認する作業ビルドを分析するための優れたツールです。

うまくいけば、これは役立ちますが、お気軽にご質問ください。

0

あなたはこのような何かを試すことができます:

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <version>${maven-dependency-plugin.version}</version> 
    <executions> 
     <execution> 
      <id>copy-dependencies</id> 
      <phase>package</phase> 
      <goals> 
       <goal>copy-dependencies</goal> 
      </goals> 
      <configuration> 
       <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory> 
       <overWriteReleases>false</overWriteReleases> 
       <overWriteSnapshots>false</overWriteSnapshots> 
       <overWriteIfNewer>true</overWriteIfNewer> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

これはApache Maven Dependency Pluginの一部です。

あなたはまた、ソースを取得したい場合は

<plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-dependency-plugin</artifactId> 
    <version>${maven-dependency-plugin.version}</version> 
    <executions> 
     <execution> 
      <id>copy-dependencies</id> 
      <phase>package</phase> 
      <goals> 
       <goal>copy-dependencies</goal> 
      </goals> 
      <configuration> 
       <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory> 
       <overWriteReleases>false</overWriteReleases> 
       <overWriteSnapshots>false</overWriteSnapshots> 
       <overWriteIfNewer>true</overWriteIfNewer> 
      </configuration> 
     </execution> 
     <execution> 
      <id>sources</id> 
      <phase>package</phase> 
      <goals> 
       <goal>copy-dependencies</goal> 
      </goals> 
      <configuration> 
       <classifier>sources</classifier> 
       <outputDirectory>${project.build.directory}/alternateLocation</outputDirectory> 
       <overWriteReleases>false</overWriteReleases> 
       <overWriteSnapshots>false</overWriteSnapshots> 
       <overWriteIfNewer>true</overWriteIfNewer> 
      </configuration> 
     </execution> 
    </executions> 
</plugin> 

とでAlternateLocationフォルダに見えます。もちろん、そのフォルダをあなたの好きな場所に変更することもできます。

関連する問題