Maven configuration items dependent method using a local repository of configuration items aggregation methods rely on the use Maven local repository summary

Configuring Maven project dependencies using the local repository method summary

 

Configuring Maven project using a local warehouse in the following ways:

1, similar to the local repository, but belongs to the local dependence, such as a JAR package is a reference to a third party, directly on the project lib folder, then the time can be configured as follows POM project:

Copy the code
      <dependency>
         <groupId>ldapjdk</groupId>
         <artifactId>ldapjdk</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\src\lib\ldapjdk.jar</systemPath>
      </dependency>
Copy the code

Description: Red part of the project location of the JAR package is located.

! A better way is to configure translation parameters <compilerArguments>, add extdirs jar package relative path to add to the configuration, as follows:

<build>
        <plugins>
            <plugin>
              <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
                  <source>1.6</source>
                  <target>1.6</target>
                  <encoding>UTF-8</encoding>
                  <compilerArguments>
                   <extdirs>src\main\webapp\WEB-INF\lib</extdirs>    <extdirs>${basedir}/WebRoot/WEB-INF/lib</extdirs>
                 </compilerArguments>
              </configuration>
            </plugin>
        </plugins>
    </build>

Description: Red part of the project location of the JAR package is located.

2, the configuration of the Maven local repository address setting.xml files, but this approach does not mean a local repository on the project, but such remote repository cache of a local directory; local warehouse on if you want to implement the project, can be used the way to solve, such as to configure a local repository directory, and then install the required JAR package to a local warehouse, the last is a direct reference to the JAR package on the project.

Configuring setttin.xml local repository directory as follows:

      <localRepository>C:/MyLocalRepository</localRepository>

Thinking installation JAR package Reference: http://www.cnblogs.com/EasonJim/p/6794423.html

3, using the Maven Deploy ( http://maven.apache.org/plugins/maven-deploy-plugin/ ) plug mvn deploy command to deploy a local folder, the file to obtain the relevant JAR package, POM configuration is as follows:

Copy the code
  <distributionManagement>
    <repository>
        <id>oss</id>
        <url>http://127.0.0.1:8081/repository/maven-releases/</url>
    </repository>
    <snapshotRepository>
        <id>oss</id>
        <url>http://127.0.0.1:8081/repository/maven-snapshots/</url>
    </snapshotRepository>
  </distributionManagement>
Copy the code

note:

  ① The above configuration is to deploy remote repository, which comprises the two addresses and release snapshot.

  ② configured to deploy a local warehouse only need to configure <repository> node can, <snapshotRepository> node removed.

  ③ reference local repository url: file: / user / jim / home / test / or file: D: / test /

Use the command: mvn deploy

After a good release the contents of an entire folder test which can be submitted directly to a remote directory or use the local directory, configure the address of the remote warehouse in the POM project, but this url node can use a local path, configuration is as follows:

<repositories>
    <repository>
        <id>jsoftlocal-mvn-repo</id>
        <url>file:D:/test/</url>
    </repository>
</repositories>

Tip: This can be a remote node url address, local area network address, the address may be a local directory.

Once configured, it can rely on its own direct configuration posted on POM. For example, I publish the test JAR packages introduced as follows:

        <dependency>
            <groupId>com.jsoft</groupId>
            <artifactId>testcommon</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>


  Maven built-in variables Description:

  • $ {Basedir} project root directory
  • $ {Project.build.directory} build directory, default target
  • $ {Project.build.outputDirectory} build process output directory, default target / classes
  • $ {Project.build.finalName} outputs the name, defaults to $ {project.artifactId} - $ {project.version}
  • $ {Project.packaging} package type, default jar
  • The content of any node $ {project.xxx} pom current file

Configuring Maven project using a local warehouse in the following ways:

1, similar to the local repository, but belongs to the local dependence, such as a JAR package is a reference to a third party, directly on the project lib folder, then the time can be configured as follows POM project:

Copy the code
      <dependency>
         <groupId>ldapjdk</groupId>
         <artifactId>ldapjdk</artifactId>
         <scope>system</scope>
         <version>1.0</version>
         <systemPath>${basedir}\src\lib\ldapjdk.jar</systemPath>
      </dependency>
Copy the code

Description: Red part of the project location of the JAR package is located.

! A better way is to configure translation parameters <compilerArguments>, add extdirs jar package relative path to add to the configuration, as follows:

<build>
        <plugins>
            <plugin>
              <artifactId>maven-compiler-plugin</artifactId>
              <configuration>
                  <source>1.6</source>
                  <target>1.6</target>
                  <encoding>UTF-8</encoding>
                  <compilerArguments>
                   <extdirs>src\main\webapp\WEB-INF\lib</extdirs>    <extdirs>${basedir}/WebRoot/WEB-INF/lib</extdirs>
                 </compilerArguments>
              </configuration>
            </plugin>
        </plugins>
    </build>

Description: Red part of the project location of the JAR package is located.

2, the configuration of the Maven local repository address setting.xml files, but this approach does not mean a local repository on the project, but such remote repository cache of a local directory; local warehouse on if you want to implement the project, can be used the way to solve, such as to configure a local repository directory, and then install the required JAR package to a local warehouse, the last is a direct reference to the JAR package on the project.

Configuring setttin.xml local repository directory as follows:

      <localRepository>C:/MyLocalRepository</localRepository>

Thinking installation JAR package Reference: http://www.cnblogs.com/EasonJim/p/6794423.html

3, using the Maven Deploy ( http://maven.apache.org/plugins/maven-deploy-plugin/ ) plug mvn deploy command to deploy a local folder, the file to obtain the relevant JAR package, POM configuration is as follows:

Copy the code
  <distributionManagement>
    <repository>
        <id>oss</id>
        <url>http://127.0.0.1:8081/repository/maven-releases/</url>
    </repository>
    <snapshotRepository>
        <id>oss</id>
        <url>http://127.0.0.1:8081/repository/maven-snapshots/</url>
    </snapshotRepository>
  </distributionManagement>
Copy the code

note:

  ① The above configuration is to deploy remote repository, which comprises the two addresses and release snapshot.

  ② configured to deploy a local warehouse only need to configure <repository> node can, <snapshotRepository> node removed.

  ③ reference local repository url: file: / user / jim / home / test / or file: D: / test /

Use the command: mvn deploy

After a good release the contents of an entire folder test which can be submitted directly to a remote directory or use the local directory, configure the address of the remote warehouse in the POM project, but this url node can use a local path, configuration is as follows:

<repositories>
    <repository>
        <id>jsoftlocal-mvn-repo</id>
        <url>file:D:/test/</url>
    </repository>
</repositories>

Tip: This can be a remote node url address, local area network address, the address may be a local directory.

Once configured, it can rely on its own direct configuration posted on POM. For example, I publish the test JAR packages introduced as follows:

        <dependency>
            <groupId>com.jsoft</groupId>
            <artifactId>testcommon</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>


  Maven built-in variables Description:

  • $ {Basedir} project root directory
  • $ {Project.build.directory} build directory, default target
  • $ {Project.build.outputDirectory} build process output directory, default target / classes
  • $ {Project.build.finalName} outputs the name, defaults to $ {project.artifactId} - $ {project.version}
  • $ {Project.packaging} package type, default jar
  • The content of any node $ {project.xxx} pom current file

Guess you like

Origin www.cnblogs.com/gaobing1252/p/11110646.html