esclipse 中关于maven配置的相关体会

本文介绍如何在 Eclipse 中配置 Maven 环境,包括设置 MAVEN_HOME 环境变量、使用阿里云作为 Maven 中央仓库来提高下载速度以及 pom.xml 文件的配置方法。此外,还提供了常用的 Maven 命令。

esclipse中maven环境的搭建:

参见相关网页,网上有大量关于搭建esclipse maven环境的文章,关键两点:

1)、一定要配置:m2_home,MAVEN_HOME的环境变量,否则,esclipse中插件不能正常使用;

2)、可以设置maven中央仓库的地址位阿里仓库地址,配置信息如下:

<mirrors>
<mirror>
<id>alimaven</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
</mirrors>

使用阿里仓库可以大大提高jar包下载速度;

3)关于pom.xml文件的配置:

pom中的内容主要分为两部分,一部分为对相关jar依赖项的定义;示例如下:

<dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
    <dependency>
    <groupId>commons-httpclient</groupId>
    <artifactId>commons-httpclient</artifactId>
    <version>3.1</version>
    </dependency>
    <dependency>
    <groupId>org.xerial</groupId>
    <artifactId>sqlite-jdbc</artifactId>
    <version>3.21.0.1</version>
</dependency>

</dependencies>

还有一部分是关于编译和部署的,示例如下:

 <build>  
       <finalName>upload_files</finalName>
       <sourceDirectory>src/main/java</sourceDirectory>           
        <plugins>  
        <!-- 编译插件 -->
      <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <defaultLibBundleDir>lib</defaultLibBundleDir>
                <source>1.8</source>
                <target>1.8</target>
                <encoding>UTF-8</encoding>
            </configuration>
        </plugin>

</build> 

常用的maven命令:

mvn compile

mvn clean

mvn package

mvn clean package

mvn clean assembly

。。。。。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值