Maven configures the local warehouse Maven project uses the local warehouse

Maven configures the local warehouse Maven project uses the local warehouse

When the project deployment or development environment does not have an external network, a local warehouse needs to be configured.

Because it is an internal network environment, maven cannot connect to the Internet, so you can only download the jar to the local in advance, and then reference the jar to the local warehouse by configuring the pom file.

Modify maven's settings.xml file

Configure the local warehouse directory

 <localRepository>/twiot/repository</localRepository>
<mirror>
      <id>central</id>
      <mirrorOf>*</mirrorOf>
      <name>central</name>
      <url>file:///twiot/repository</url>
    </mirror>

Modify the pom.xml in the maven project

Add the following configuration

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

Configure environment variables

cat /etc/profile

export JAVA_HOME=/home/software/jdk1.8.0_251
export MAVEN_HOME=/home/software/apache-maven-3.6.3
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin:$MAVEN_HOME/bin

Reference link:
https://blog.csdn.net/qq_44697728/article/details/127223407

Guess you like

Origin blog.csdn.net/yinjl123456/article/details/127621082