mvn:install to place my jar in nexus remote reposi

2019-03-15 02:52发布

问题:

I am using maven in eclipse (m2 eclipse)

When i execute mvn:install i want my jar(artifact) to be installed in the nexus repository which is located on the server(right now the installed jar is placed in the local system repository).. how can i do that ?

I even changed this to my local repository address

回答1:

Typically, you'd use mvn deploy to deploy to a non-local repository.

You will, of course, need to have the repo configured, either in your maven settings.xml or in the project POM.

As we always use the same internal repo, I've done this in the Maven settings.xml, more precisely, the "profiles" section.

Here is my config for reference:

  <profiles>
    <profile>
      <id>artifactory</id>
      <repositories>
        <repository>
          <id>central</id>
          <name>libs-releases</name>
          <url>http://repo.example.com/libs-releases</url>
          <snapshots>
            <enabled>false</enabled>
          </snapshots>
        </repository>
        <repository>
          <id>snapshots</id>
          <name>libs-snapshots</name>
          <url>http://repo.example.com/libs-snapshots</url>
          <snapshots />
        </repository>
      </repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <name>plugins-releases</name>
          <url>http://repo.example.com/plugins-releases</url>
          <snapshots><enabled>false</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>artifactory</activeProfile>
  </activeProfiles>