maven eclipse的使用和配置

2025-11-24 01:47:05

1、http://maven.apache.org/download.cgi下载maven

2、解压maven,在目录apache-maven-3.5.2\conf(找到自己解压后对应的目录)下找到settings.xml,打开进行编辑

   (1)添加<localRepository>D:/.m2/repository</localRepository>,指定默认的本地仓库更改到D:/.m2/repository

    (2)需要自行添加其它的镜像地址

<mirror>  

         <id>ibiblio</id>  

         <mirrorOf>central</mirrorOf>  

         <name>Human Readable Name for this Mirror.</name>  

         <url>http://mirrors.ibiblio.org/maven2/</url>  

     </mirror>  

(3)jdk版本    

[html] view plain copy

<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>   

    

(4)测试一下cmd输入mvn help:system ,开始从远程仓库下载很多东西

3、 eclipse配置

       (1)选择window-preferences 双击Maven,点击Installations,点击add的maven目录bin的上一次并打钩,点击User Settings 选择Maven目录的刚刚修改的settings.xml

        (2)eclipse还需要安装m2eclipse插件,Help-instance New SoftWare...”菜单项 ,点击add自己起一个名字 Location输入:                                                                                            http://download.eclipse.org/technology/m2e/releases,选中“Maven Integration for Eclipse”前面的复选框然后next

        (3)配置好后右键java web项目选择Configure---Convert to mave project即可,在pom.xml中配置引用jar包例如

<properties>  

          

        <struts2.version>2.5.13</struts2.version>  

          

    </properties>  

          <dependency>  

            <groupId>org.apache.struts</groupId>  

            <artifactId>struts2-core</artifactId>  

            <version>${struts2.version}</version>  

            <scope>runtime</scope>  

        </dependency>  

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢