首页 > 其他分享 >Maven踩坑实录

Maven踩坑实录

时间:2023-08-29 21:46:59浏览次数:37  
标签:maven basedir project plugin maven2 实录 Maven

本文记录学习or工作时一些Maven常见操作以及踩坑的地方,以此文做以记录。

一、Maven如何使用私服地址

  在工作中,有的jar包是放在私服上面的,这时候我们在mvn install的时候想要的是从私服下载jar包,此处我就踩了坑。

SpringBoot项目,通过mvn install,Maven一直从maven2仓库进行下载,我明明没有在项目或者setting.xml中配置Maven2仓库的url路径啊?

查阅资料得知,原来 springboot的pom文件都继承了super pom.而super pom中配置的就是maven2,关于如何查询maven2配置,路径如下:

$MAVEN_HOME/lib/maven-model-builder-xxx/org/apache/maven/model/pom-4.0.0.xml
<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!-- START SNIPPET: superpom -->
<project>
  <modelVersion>4.0.0</modelVersion>

  <repositories>
    <repository>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>

  <pluginRepositories>
    <pluginRepository>
      <id>central</id>
      <name>Central Repository</name>
      <url>https://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <releases>
        <updatePolicy>never</updatePolicy>
      </releases>
    </pluginRepository>
  </pluginRepositories>

  <build>
    <directory>${project.basedir}/target</directory>
    <outputDirectory>${project.build.directory}/classes</outputDirectory>
    <finalName>${project.artifactId}-${project.version}</finalName>
    <testOutputDirectory>${project.build.directory}/test-classes</testOutputDirectory>
    <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory>
    <scriptSourceDirectory>${project.basedir}/src/main/scripts</scriptSourceDirectory>
    <testSourceDirectory>${project.basedir}/src/test/java</testSourceDirectory>
    <resources>
      <resource>
        <directory>${project.basedir}/src/main/resources</directory>
      </resource>
    </resources>
    <testResources>
      <testResource>
        <directory>${project.basedir}/src/test/resources</directory>
      </testResource>
    </testResources>
    <pluginManagement>
      <!-- NOTE: These plugins will be removed from future versions of the super POM -->
      <!-- They are kept for the moment as they are very unlikely to conflict with lifecycle mappings (MNG-4453) -->
      <plugins>
        <plugin>
          <artifactId>maven-antrun-plugin</artifactId>
          <version>1.3</version>
        </plugin>
        <plugin>
          <artifactId>maven-assembly-plugin</artifactId>
          <version>2.2-beta-5</version>
        </plugin>
        <plugin>
          <artifactId>maven-dependency-plugin</artifactId>
          <version>2.8</version>
        </plugin>
        <plugin>
          <artifactId>maven-release-plugin</artifactId>
          <version>2.5.3</version>
        </plugin>
      </plugins>
    </pluginManagement>
  </build>

  <reporting>
    <outputDirectory>${project.build.directory}/site</outputDirectory>
  </reporting>

  <profiles>
    <!-- NOTE: The release profile will be removed from future versions of the super POM -->
    <profile>
      <id>release-profile</id>

      <activation>
        <property>
          <name>performRelease</name>
          <value>true</value>
        </property>
      </activation>

      <build>
        <plugins>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-source-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-sources</id>
                <goals>
                  <goal>jar-no-fork</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-javadoc-plugin</artifactId>
            <executions>
              <execution>
                <id>attach-javadocs</id>
                <goals>
                  <goal>jar</goal>
                </goals>
              </execution>
            </executions>
          </plugin>
          <plugin>
            <inherited>true</inherited>
            <artifactId>maven-deploy-plugin</artifactId>
            <configuration>
              <updateReleaseInfo>true</updateReleaseInfo>
            </configuration>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

</project>
<!-- END SNIPPET: superpom -->
pom-4.0.0.xml

 

可以看到是在此文件中配置了maven2仓库地址: https://repo.maven.apache.org/maven2 

 

标签:maven,basedir,project,plugin,maven2,实录,Maven
From: https://www.cnblogs.com/zhangzhixi/p/17665906.html

相关文章

  • [Maven] Maven scope 总结
    1问题背景1.1一起mavendependencyscope:=provided引发的事故今天在运行科室的bdp-common-resource工程时,在src/main目录下一个类中插入了一段含main方法的临时调试代码:importlombok.extern.slf4j.Slf4j;//...@Slf4jpublicclassDBCFileUtils{//...p......
  • 【maven】idea运行项目的时候,因为依赖maven坐标是provided报错NoClassDefFoundError解
    1、查看报错的类的生命周期-基于在idea安装mavenhelper插件  2、在运行maven项目的入口新增配置项 ......
  • Maven的安装与环境变量的配置
    Maven的安装与环境变量的配置1、下载安装maven2、配置环境变量在系统环境变量中加入MAVEN_HOME这个的路径就是maven的安装路径M2_HOME这个是maven目录下的bin目录中还要再path路径下配置:%MAVEN_HOME%\bin3、阿里云镜像的配置因为国内有墙,所以要使用aliyu......
  • Maven配置详解
    <projectxmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/maven-v4_0_0.xsd">......
  • Maven plugin中的lifecycle、phase、goal、mojo概念及作用的理解
       首先,说些题外话,maven的plugin真的很容易写,很多时候,我们只是被plugin这个词吓倒了,总以为插件这玩意,是专家才能写的,我maven都没精通,怎么写得出自己的plugin呢,其实不然,起码在maven中,写一个自己的plugin还是非常简单的,其它软件的插件,要看情况,有些的确是要天才级人物才写得出,......
  • Maven的发布plugin配置
    <build> <plugins> <plugin> <!--编译插件--> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <......
  • 基于security的前后端分离项目尝试踩坑和解决实录
    到访游客请注意,如果你有相似的问题,请不要跟着步骤,这里记录的是踩坑和解决解决在最后:debug不如rebuild:)开始踩坑坑1:首先是数据库设计很自然的想到用户登录是一个表。用户需要权限角色,可能一对多,所以出现了角色表。这些接口有哪些角色可以使用。出现第一个大坑。security的......
  • 安装Maven
    maven官方的中央仓库:https://mvnrepository.com/1、下载maven//Maven下载地址https://maven.apache.org/download.cgihttps://maven.apache.org/docs/history.html2、安装maven]#tarzvfx./apache-maven-3.9.4-bin.tar.gz-C/usr/local/]#cd/usr/local/]#ln-......
  • Unable to update index for central http://repo1.maven.org/maven2/
    Unable to update index for central http://repo1.maven.org/maven2/ 就是这句,myeclipse启动后控制台输出这句话:解决办法:1.在myeclipse3.4(我用的这个版本)里面Window => Preferences => Myeclipse Enterprise Workbench => Maven4Myeclipse => Maven=>禁用Downloa......
  • 在maven中使用tomcat插件运行项目
    1.在pom.xml中配置插件<plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat7-maven-plugin</artifactId><version>2.2</version><configuration>......