Maven环境的搭建与idea配置

25 篇文章 0 订阅

Maven环境的搭建与idea配置

Maven 下载: http://maven.apache.org/download.cgi

Maven 中央仓库地址: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 plain  copy
  1. <localRepository>D:/workspace/maven/stone</localRepository>  


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

[html]  view plain  copy
  1. <profiles>  
  2.     <profile>  
  3.         <id>nexus</id>  
  4.         <repositories><!--配置远程仓库-->  
  5.             <repository>  
  6.                 <id>nexus</id>  
  7.                 <name>Central Repository</name>  
  8.                 <url>http://127.0.0.1/nexus/content/groups/public</url>  
  9.                 <releases>  
  10.                     <enabled>true</enabled>  
  11.                 </releases>  
  12.                 <snapshots>  
  13.                     <enabled>false</enabled><!---->  
  14.                 </snapshots>  
  15.             </repository>  
  16.         </repositories>  
  17.         <pluginRepositories><!--配置Maven从什么地方下载插件构件-->  
  18.             <pluginRepository>  
  19.                 <id>nexus</id>  
  20.                 <name>Central Repository</name>  
  21.                 <url>http://127.0.0.1/nexus/content/groups/public</url>  
  22.                 <releases>  
  23.                     <enabled>true</enabled>  
  24.                 </releases>  
  25.                 <snapshots>  
  26.                     <enabled>false</enabled>  
  27.                 </snapshots>  
  28.             </pluginRepository>  
  29.         </pluginRepositories>  
  30.     </profile>  
  31. </profiles>  
  32.   
  33. <activeProfiles><!--激活 远程仓库-->  
  34.         <activeProfile>nexus</activeProfile>  
  35. </activeProfiles>  


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

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

[html]  view plain  copy
  1. <mirrors>  
  2. <mirror><!--配置镜像-->  
  3.     <id>nexus</id>  
  4.     <mirrorOf>*</mirrorOf>  
  5.     <url>http://127.0.0.1/nexus/content/groups/public</url>  
  6. </mirror>  
  7. </mirrors>  

3、pom.xml文件配置依赖

[html]  view plain  copy
  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
  2.          xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">  
  3.     <modelVersion>4.0.0</modelVersion>  
  4.     <groupId>xu.feifei</groupId>  
  5.     <artifactId>feifei</artifactId>  
  6.     <packaging>war</packaging>  
  7.     <version>1.0</version>  
  8.   
  9.     <dependencies>  
  10.   
  11.         <dependency>  
  12.             <groupId>junit</groupId>  
  13.             <artifactId>junit</artifactId>  
  14.             <version>3.8.1</version>  
  15.             <scope>test</scope>  
  16.         </dependency>  
  17.         <dependency>  
  18.             <groupId>org.json</groupId>  
  19.             <artifactId>json</artifactId>  
  20.             <version>20090211</version>  
  21.         </dependency>  
  22.   
  23.     </dependencies>  
  24.   
  25.     <build>  
  26.         <finalName>feifei</finalName>  
  27.     </build>  
  28.       
  29. </project>  

二、IDEA的搭建Maven相关配置

.


maven项目的包结构


设置maven自动导包






  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值