设为首页收藏本站

数码鹭岛论坛

 找回密码
 注-册

QQ登录

只需一步,快速开始

搜索
查看: 1853|回复: 0
打印 上一主题 下一主题

Maven环境的搭建与idea配置

[复制链接]
跳转到指定楼层
1#
发表于 2014-12-30 09:06:37 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
Maven环境的搭建与idea配置

Maven 下载: [url=http://maven.apache.org/download.cgi]http://maven.apache.org/download.cgi

Maven 中央仓库地址:[url=http://search.maven.org]http://search.maven.org

配置maven环境变量

M2_HOME:D:\workspace\maven\apache-maven-3.0.5

Path:;%M2_HOME%/bin;

检查是否成功,打开CMD:

Mvn -v

mvn install 会将项目生成的构件安装到本地Maven仓库

mvn deploy 用来将项目生成的构件分发到远程Maven仓库

D:\>mvn archetype:generate:在D:盘构建maven标准项目目录结构

2、settings.xml文件配置

2.0修改本地仓库位置

M2_home目录下 conf/settings.xml

[html] view plaincopy

    <localRepository>D:/workspace/maven/stone</localRepository>  



2.1如何配置远程仓库(私服): (nexus-2.0.4-1-bundle)

[html] view plaincopy

    <profiles>  
        <profile>  
            <id>nexus</id>  
            <repositories><!--配置远程仓库-->  
                <repository>  
                    <id>nexus</id>  
                    <name>Central Repository</name>  
                    <url>[url=http://127.0.0.1/nexus/content/groups/public</url]http://127.0.0.1/nexus/content/groups/public</url>  
                    <releases>  
                        <enabled>true</enabled>  
                    </releases>  
                    <snapshots>  
                        <enabled>false</enabled><!---->  
                    </snapshots>  
                </repository>  
            </repositories>  
            <pluginRepositories><!--配置Maven从什么地方下载插件构件-->  
                <pluginRepository>  
                    <id>nexus</id>  
                    <name>Central Repository</name>  
                    <url>[url=http://127.0.0.1/nexus/content/groups/public</url]http://127.0.0.1/nexus/content/groups/public</url>  
                    <releases>  
                        <enabled>true</enabled>  
                    </releases>  
                    <snapshots>  
                        <enabled>false</enabled>  
                    </snapshots>  
                </pluginRepository>  
            </pluginRepositories>  
        </profile>  
    </profiles>  
      
    <activeProfiles><!--激活 远程仓库-->  
            <activeProfile>nexus</activeProfile>  
    </activeProfiles>  



-------------------------------------------------------------------------------------------------

2.2还可以配置仓库的镜像下载

[html] view plaincopy

    <mirrors>  
    <mirror><!--配置镜像-->  
        <id>nexus</id>  
        <mirrorOf>*</mirrorOf>  
        <url>[url=http://127.0.0.1/nexus/content/groups/public</url]http://127.0.0.1/nexus/content/groups/public</url>  
    </mirror>  
    </mirrors>  


3、pom.xml文件配置依赖

[html] view plaincopy

    <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 [url=http://maven.apache.org/maven-v4_0_0.xsd]http://maven.apache.org/maven-v4_0_0.xsd">  
        <modelVersion>4.0.0</modelVersion>  
        <groupId>xu.feifei</groupId>  
        <artifactId>feifei</artifactId>  
        <packaging>war</packaging>  
        <version>1.0</version>  
      
        <dependencies>  
      
            <dependency>  
                <groupId>junit</groupId>  
                <artifactId>junit</artifactId>  
                <version>3.8.1</version>  
                <scope>test</scope>  
            </dependency>  
            <dependency>  
                <groupId>org.json</groupId>  
                <artifactId>json</artifactId>  
                <version>20090211</version>  
            </dependency>  
      
        </dependencies>  
      
        <build>  
            <finalName>feifei</finalName>  
        </build>  
         
    </project>  


二、IDEA的搭建Maven相关配置.



maven项目的包结构

设置maven自动导包



























分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 分享分享
您需要登录后才可以回帖 登录 | 注-册

本版积分规则

小黑屋|手机版|Archiver|数码鹭岛 ( 闽ICP备20006246号 )  

counter

GMT+8, 2025-12-3 16:26 , Processed in 0.075464 second(s), 23 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表