eclipse------maven build

There are two ways to configure the environment configuration of maven. I recommend the second one, which is to use the local maven installation file. Personally, I feel that it is convenient to manage the storage location of the downloaded jar package, the output of error messages, etc., which can be displayed in the dos window. It can be clearly seen that although it is more troublesome, you have to type the dos command every time, but you can write a batch file to solve it.

Method 1: Do not use the local maven installation file environment configuration (that is, use the default configuration of the m2eclipse plugin)

 

settings.xml sets localRepository as shown in the following code: (address can be customized)

1 <localRepository>D:/Development/m2/repository</localRepository>

     Indicates that if localRepository is not set, maven will build the local repository into the /.m2/repository folder by default. The above setting means to create a local warehouse under the D:/Development/m2/repository folder.
     Personally, it is recommended not to use the default warehouse address, because if there are many projects, the disk space occupied by the local warehouse will be more, so specifying the warehouse address to another drive letter is more convenient for management.

 

Method 2: Use the local maven environment

    Before installing Maven, you need to make sure that your JDK has been installed and configured. Maven is a project under Apache, and my new version is 3.0.4, which is what I use.

    1. First go to the official website to download Maven: http://www.apache.org/dyn/closer.cgi/maven/binaries/apache-maven-3.0.4-bin.tar.gz

    2. Configure maven environment variables:

        System variable: MAVEN_HOME=D:\Development\apache-maven-3.0.4

        System variable: path = %MAVEN_HOME%\bin

        I believe that everyone has already configured environment variables, so I won't go into the detailed steps, but it's OK to match the attribute name and attribute value.

        Open cmd and type in: mvn -version

        

        If the above information can be printed, it means that Maven3 has been installed on your computer.

        mvn is an instruction of maven, mvn -version is to view version information, my operating system is 32-bit WIN7, and the installed maven is 3.0.4

        If the above information can be printed, it means that Maven3 has been installed on your computer.

     3.eclipse configure maven:

        (1) .Click  the  Add  button and select the path value where  Maven  is installed on your local machine

           

          (2) In Preferences-->Maven-->User Settings, click Update Settings to load the changes we just made to settings.xml

          
   

    4. Modify the storage location of the maven local warehouse:

       Find the settings.xml configuration file under conf under apache-maven-3.0.4, mine is in D:\Development\apache-maven-3.0.4\conf\settings.xml

       

        apache-maven-3.0.4的仓库默认是放在本地用户的临时文件夹下面的 .m2 文件夹下的 repository 下,我的是在 C:\Users\Administrator\.m2\repository 目录下, 
        现在我们来修改将它指定到我们自己的路径下,我现在要将仓库指定到 D:/Development/m2/repository 目录下,只需要将上面注销的本地仓库打开,

         然后把相应的路径值写到里面去就行了:
         

 

 附:Maven常用指令

  

 
1.创建简单的maven 的web项目
    mvn archetype:create 
    举例:mvn archetype:create  -DgroupId=com.demo.app -DartifactId=demo-app  -DarchetypeArtifactId=maven-archetype-webapp

2.生成和清除Eclipse项目结构:
   mvn eclipse:eclipse 将maven项目变成eclipse,其实是在项目中生成 .project 和 .classpath 两个文件
   mvn eclipse:clean 清理(删除target目录下编译内容)
   mvn clean 打包发布
 

 

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326568600&siteId=291194637