Centos 7 Linux配置离线/在线maven

maven配

下载maven包上传到服务器并解压

下面的配置是离线环境的配置

在服务器的mavensetting.xml文件中添加如下内容

  <localRepository>/sga/maven/apache-maven-3.6.3/repository</localRepository>

  <offline>true</offline>

<mirror>

      <id>central</id>

      <mirrorOf>*</mirrorOf>

      <name>central</name>

      <url>file:///sga/maven/apache-maven-3.6.3/repository</url>

 </mirror>

下面的配置是在线环境的配置

    <localRepository>/home/maven-repository</localRepository>

    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://10.122.100.161:8081/repository/ciems-group/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>

2 配置mvn环境变量

vim /etc/profile

export MAVEN_HOME=/home/apache-maven-3.5.4
export PATH=$PATH:$MAVEN_HOME/bin

使修改生效

source /etc/profile

pom依赖设置

设置打包的包名

<build>模块加入以下内容

<finalName>test</finalName>

pom文件中加入以下依赖

 <build>
    <finalName>test-name</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>2.5.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
                <!--<encoding>${project.build.sourceEncoding}</encoding> -->
            </configuration>
        </plugin>
        <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.18.1</version>
        <configuration>
            <skipTests>true</skipTests>
        </configuration>
    </plugin>
    </plugins>
</build>

4 一些报错

jenkins maven打包报错

[ERROR] Error executing Maven.

[ERROR] The specified user settings file does not exist: /sga/maven/apache-maven-3.6.3

写错了setting文件位置,在构建中的maven配置中点击高级,配置setting文件位置

posted @ 2020-07-09 14:45  卡拉没  阅读(637)  评论(0)    收藏  举报