配置Maven本地仓库

1、下载解压缩Maven到本地目录

D:\apache-maven-3.3.9

2、配置Maven本地仓库

打开D:\apache-maven-3.3.9\conf\settings.xml

在第55行附近添加:

  <localRepository>d:\Library\maven-repo</localRepository>

在第213行附近添加:

    <profile>
         <id>jdk-1.8</id>
            <activation>
                      <activeByDefault>true</activeByDefault>
                     <jdk>1.8</jdk>
              </activation>
             <properties>
                      <maven.compiler.source>1.8</maven.compiler.source>
                  <maven.compiler.target>1.8</maven.compiler.target>
                  <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
                </properties>
     </profile>

3、添加一个自定义jar到本地仓库中

D:\apache-maven-3.3.9\bin>mvn install:install-file -Dfile=C:/Users/leizm/Desktop/ansj_seg-5.0.0-all-in-one.jar -DgroupId=org.ansj -DartifactId=ansj_seg -Dversio n=5.0.0 -Dpackaging=jar

那么在pom.xml中的依赖配置为:

<dependency>
    <groupId>org.ansj</groupId>
    <artifactId>ansj_seg</artifactId>
    <version>5.0.0</version>
</dependency>

执行命令如下:

D:\apache-maven-3.3.9\bin>mvn install:install-file -Dfile=C:/Users/leizm/Desktop
/ansj_seg-5.0.0-all-in-one.jar -DgroupId=org.ansj -DartifactId=ansj_seg -Dversio
n=5.0.0 -Dpackaging=jar
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom
---
[INFO] Installing C:\Users\leizm\Desktop\ansj_seg-5.0.0-all-in-one.jar to d:\Lib
rary\maven-repo\org\ansj\ansj_seg\5.0.0\ansj_seg-5.0.0.jar
[INFO] Installing C:\Users\leizm\AppData\Local\Temp\mvninstall158649410227741988
1.pom to d:\Library\maven-repo\org\ansj\ansj_seg\5.0.0\ansj_seg-5.0.0.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.793 s
[INFO] Finished at: 2016-07-04T17:15:43+08:00
[INFO] Final Memory: 8M/241M
[INFO] ------------------------------------------------------------------------

D:\apache-maven-3.3.9\bin>

4、给出一个实际的pom.xml文件

<project xmlns="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.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.lfw</groupId>
    <artifactId>lfwsv</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>lfwsv Maven Webapp</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <!--框架-->
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>aopalliance</groupId>
            <artifactId>aopalliance</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjrt</artifactId>
            <version>1.8.4</version>
        </dependency>
        <dependency>
            <groupId>org.aspectj</groupId>
            <artifactId>aspectjweaver</artifactId>
            <version>1.7.3</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2.2</version>
        </dependency>
        <dependency>
            <groupId>commons-logging</groupId>
            <artifactId>commons-logging</artifactId>
            <version>1.1.3</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-log4j12</artifactId>
            <version>1.7.5</version>
        </dependency>
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
        <dependency>
            <groupId>dom4j</groupId>
            <artifactId>dom4j</artifactId>
            <version>1.6.1</version>
        </dependency>
        <dependency>
            <groupId>xml-apis</groupId>
            <artifactId>xml-apis</artifactId>
            <version>1.0.b2</version>
        </dependency>
        <dependency>
            <groupId>commons-beanutils</groupId>
            <artifactId>commons-beanutils</artifactId>
            <version>1.8.3</version>
        </dependency>
        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>commons-collections</groupId>
            <artifactId>commons-collections</artifactId>
            <version>3.2.1</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.10</version>
        </dependency>
        <dependency>
            <groupId>commons-dbcp</groupId>
            <artifactId>commons-dbcp</artifactId>
            <version>1.4</version>
        </dependency>
        <dependency>
            <groupId>commons-fileupload</groupId>
            <artifactId>commons-fileupload</artifactId>
            <version>1.3.1</version>
        </dependency>
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>
        <dependency>
            <groupId>commons-lang</groupId>
            <artifactId>commons-lang</artifactId>
            <version>2.6</version>
        </dependency>
        <dependency>
            <groupId>commons-pool</groupId>
            <artifactId>commons-pool</artifactId>
            <version>1.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-pool2</artifactId>
            <version>2.3</version>
        </dependency>

        <dependency>
            <groupId>net.sf.ehcache</groupId>
            <artifactId>ehcache-core</artifactId>
            <version>2.5.0</version>
        </dependency>
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>fastjson</artifactId>
            <version>1.2.11</version>
        </dependency>

        <!-- alibaba连接池-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid</artifactId>
            <version>1.0.19</version>
        </dependency>
        <!--junit-->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-core</artifactId>
            <version>1.3</version>
        </dependency>

        <!--jackson-->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-annotations</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-core</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.3.1</version>
        </dependency>
        <dependency>
            <groupId>com.fasterxml.jackson.module</groupId>
            <artifactId>jackson-module-jaxb-annotations</artifactId>
            <version>2.3.1</version>
        </dependency>
        <!--mybatis-->
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis</artifactId>
            <version>3.2.8</version>
        </dependency>
        <dependency>
            <groupId>org.mybatis</groupId>
            <artifactId>mybatis-spring</artifactId>
            <version>1.3.0</version>
        </dependency>
        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.38</version>
        </dependency>

        <!--spring-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aspects</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-aop</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-beans</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context-support</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-core</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-expression</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-instrument</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-instrument-tomcat</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jdbc</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-oxm</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-web</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
            <version>3.2.12.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-redis</artifactId>
            <version>1.4.2.RELEASE</version>
        </dependency>

        <!-- poi-->
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi</artifactId>
            <version>3.11</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.11</version>
        </dependency>
        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml-schemas</artifactId>
            <version>3.11</version>
        </dependency>
        <dependency>
            <groupId>org.apache.xmlbeans</groupId>
            <artifactId>xmlbeans</artifactId>
            <version>2.6.0</version>
        </dependency>

        <!-- itext-->
        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itextpdf</artifactId>
            <version>5.4.5</version>
        </dependency>
        <dependency>
            <groupId>com.itextpdf</groupId>
            <artifactId>itext-asian</artifactId>
            <version>5.2.0</version>
        </dependency>

        <!-- freemarker-->
        <dependency>
            <groupId>freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.2</version>
        </dependency>

        <!-- httpclient-->
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpcore</artifactId>
            <version>4.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>4.4.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient-cache</artifactId>
            <version>4.4.1</version>
        </dependency>

        <!--工具包-->
        <dependency>
            <groupId>com.github.cage</groupId>
            <artifactId>cage</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>net.coobird</groupId>
            <artifactId>thumbnailator</artifactId>
            <version>0.4.8</version>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>1.4.190</version>
        </dependency>
        <dependency>
            <groupId>redis.clients</groupId>
            <artifactId>jedis</artifactId>
            <version>2.6.2</version>
        </dependency>
        <dependency>
            <groupId>jstl</groupId>
            <artifactId>jstl</artifactId>
            <version>1.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.tomcat</groupId>
            <artifactId>servlet-api</artifactId>
            <version>3.0</version>
        </dependency>
        <dependency>
            <groupId>framework</groupId>
            <artifactId>framework</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>org.ansj</groupId>
            <artifactId>ansj_seg</artifactId>
            <version>5.0.0</version>
        </dependency>
    </dependencies>

    <!-- 发布路径-->
    <!--<distributionManagement>-->
    <!--&lt;!&ndash; 正式版发布路径&ndash;&gt;-->
    <!--<repository>-->
    <!--<id>nexus-releases</id>-->
    <!--<name>Nexus Release Repository</name>-->
    <!--<url>http://192.168.1.200:8081/nexus/content/repositories/releases/</url>-->
    <!--</repository>-->
    <!--&lt;!&ndash; 快照版发布路径&ndash;&gt;-->
    <!--<snapshotRepository>-->
    <!--<id>nexus-snapshots</id>-->
    <!--<name>Nexus Snapshot Repository</name>-->
    <!--<url>http://192.168.1.200:8081/nexus/content/repositories/snapshots/</url>-->
    <!--</snapshotRepository>-->
    <!--</distributionManagement>-->

    <properties>
        <!-- 文件拷贝时的编码 -->
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <!-- 编译时的编码 -->
        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
    </properties>

    <build>
        <finalName>lfwsv</finalName>

        <!-- 声明不需要web.xml-->
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>utf-8</encoding>
                </configuration>
            </plugin>
            <!--<plugin>-->
            <!--<groupId>org.apache.maven.plugins</groupId>-->
            <!--<artifactId>maven-war-plugin</artifactId>-->
            <!--<configuration>-->
            <!--<failOnMissingWebXml>false</failOnMissingWebXml>-->
            <!--</configuration>-->
            <!--</plugin>-->
        </plugins>
        <!-- 设置xml文件打包时保留-->
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>
    </build>
</project>
时间: 2024-10-07 21:18:07

配置Maven本地仓库的相关文章

Maven本地仓库配置及修改Maven的本地仓库路径

安装Maven后我们会在用户目录下发现.m2 文件夹.默认情况下,该文件夹下放置了Maven本地仓库.m2/repository.所有的Maven构件(artifact)都被存储到该仓库中,以方便重用.但是windows用户的操作系统都安装在C盘,把Maven仓库放到C盘是很危险的,为此我们需要修改Maven的本地仓库路径. 修改方式如下:     1.手动创建本地仓库的存放路径,例如:D:\Java\m2\repository:     2.在windows的环境变量中增加了新的用户变量M2_

maven 本地仓库的配置以及如何修改默认.m2仓库位置

通过修改本地 .m2目录下的settings.xml文件(没有就新建一个) 具体就是修改如下的Xml代码 <settings>     <localRepository>自己仓库的存放目录,我的仓库已经移动到e盘了,具体看上面的那个图的箭头所指的位置</localRepository>   </settings> 如下图,看到在 intelliJ idea 编辑器里面对maven进行配置. 一般默认配置是这样的: 这样的话,你就修改他默认位置的setting

maven本地仓库.m2文件夹路径讲解

Maven是一个项目管理工具,它包含了一个项目对象模型 (Project Object Model),一组标准集合,一个项目生命周期(Project Lifecycle),一个依赖管理系统(Dependency Management System),和用来运行定义在生命周期阶段(phase)中插件(plugin)目标(goal)的逻辑.当你使用Maven的时候,你用一个明确定义的项目对象模型来描述你的项目,然后Maven可以应用横切的逻辑,这些逻辑来自一组共享的(或者自定义的)插件. 基本的常用

maven 本地仓库和远程仓库

在Maven中,任何一个依赖.插件或者项目构建的输出,都可以称之为构件. Maven在某个统一的位置存储所有项目的共享的构件,这个统一的位置,我们就称之为仓库.(仓库就是存放依赖和插件的地方) 任何的构件都有唯一的坐标,Maven根据这个坐标定义了构件在仓库中的唯一存储路径, 解读Maven在仓库中的存储路径: 1.基于groupId准备路径,将句点分隔符转成路径分隔符,就是将  "."  转换成 "/" ; example: org.testng --->o

创建 maven 本地仓库;

在 pom.xml 添加依赖包的时候,有时候会提示无法从 http://repo1.maven.org/maven2/ 获取的情况,这时可配置个本地仓库: 从网上下载 maven 仓库网站源码包 Nexus 的 war 包,放到 Tomcat 安装目录的 webapps 下,建议可下载个 单机版的 tomcat ,配置个未使用 端口,这样可与开发环境一起使用: 启动 Tomcat ,可能要稍微等活,Tomcat 输入日志显示可能需要下载 一些插件,运行后打开网站: http://127.0.0.

nexus 搭建maven本地仓库

使用Nexus搭建Maven本地仓库 阅读目录 序 Nexus 序 在工作中可能存在有些开发机器不能上网,大量的机器获取jar包会导致公司网络很慢,还有时候公司会自己发布自己的项目版本,其他的项目可能会依赖引用到,所以就需要用到Maven的本地仓库. 下面就这个构建本地Maven仓库进行阐述. Nexus 一:介绍 Nexus是Maven的仓库管理器,用来搭建一个本地仓库服务器,这样做的好处便于管理,节约网络资源, 速度快,可以通过SNAPSHOT版本控制,开进行模块间的高效依赖开发. 二:下载

Maven本地仓库及远程仓库

转载自:http://blog.csdn.net/wanghantong/article/details/36427433 Maven 仓库的分类: maven的仓库只有两大类:1.本地仓库 2.远程仓库,在远程仓库中又分成了3种:2.1 中央仓库 2.2 私服 2.3 其它公共库 maven本地仓库的默认位置:无论是Windows还是Linux,在用户的目录下都有一个.m2/repository/的仓库目录,这就是Maven仓库的默认位置 如何更改maven默认的本地仓库的位置:这里要引入一个

记 Maven 本地仓库埋坑之依赖包为何不能用

记一次 Maven 本地仓库埋坑之 Verifying Availability 背景 某 Java 后端项目使用 maven 构建,因为某些原因,某些依赖库下载不了,直接找其它人索要了他电脑上的 maven 本地仓库里的依赖包. 然后直接拷贝到我电脑的本地 maven 仓库里,但构建项目时,发现,仍旧报找不到依赖包也下载不了的错误,导致项目构建不起来. 异常信息 以上是背景,下面是构建过程出现的一些异常: The Pom for xxx.jar is missing, no dependenc

Maven本地仓库

Maven本地仓库是一个文件夹,用于存储Maven自动下载下来的文件(*.jar或其它文件),简单的说就是,当你用Maven构建一个项目后,该项目所依赖的文件都会被存储在这个地方. 本地仓库默认路径: Unix/Mac OS X – ~/.m2 Windows – C:\Documents and Settings\{your-username}\.m2 当然,我们可以自己修改这个存储路径,打开Maven的配置文件 settings.xml,找到如下内容,去掉注释后,改成自己想要的路径,然后保存