Use IntelliJ IDEA to configure Maven (Getting Started) and intellijmaven

Source: Internet
Author: User

Use IntelliJ IDEA to configure Maven (Getting Started) and intellijmaven

Are you learning Maven? Is it because Maven is difficult to use and has to be used? Are you confused about the conflicts between Eclipse and Maven? So I will tell you a more direct and simpler solution: IntelliJ IDEA!

1. What is Maven and why Maven is used instead of Ant?

Maven is a project management tool and is considered a substitute or successor of Ant. In fact, Maven functions far exceed Ant. It not only provides compiled scripts, but also provides testing, release, document generation, and other functions throughout the entire project cycle, it also has a unique dependency management method. However, the cost of powerful functions is complicated usage. The first time Maven is used, it usually takes nearly half an hour (domestic network speed) to download a local dependent library, this will undoubtedly make it difficult for many developers to leave ". Despite the widespread criticism, Maven gradually replaced Ant and became a necessary skill for Java developers.

2. IntelliJ IDEA and Eclipse

In the world of Java, Eclipse is undoubtedly the leader in IDE. IntelliJ IDEA and NetBeans can only live in the halo of Eclipse. I don't need to talk about the power of Eclipse, but IntelliJ IDEA is actually a very good IDE, especially in its intelligence. Its Clone product ReSharper for. Net has been accepted by more and more C # developers. IntelliJ IDEA provides a large number of intelligent rules to help developers, such as code completion, usage conversion, format prompts, etc. When you get used to it, you will love the light bulb.

3. Reasons for choosing Maven + IntelliJ IDEA

IntelliJ IDEA is selected because Maven + Eclipse is too difficult to use. Eclipse has two Maven plug-ins: m2eclipse and Eclipse IAM. However, due to the conflict between Eclipse and Maven design, these two plug-ins may not achieve the desired effect. M2eclipse regards all your types of projects as Maven projects, which may be a disaster for a pure Java project and a JEE or WEB project. Eclipse IAM does not change the type of your project, but its functions are limited to editing and running POM files, and even dependency management is impossible. In contrast, if you have to use Eclipse, I recommend you use Eclipse IAM. To perfectly support Maven, Eclipse may need to make some changes in the underlying design. Both code specifications, project structure specifications, and dependency management have irreconcilable conflicts. Obviously, IntelliJ IDEA is much better in this aspect, so it is hard to say that you are not satisfied with it.

4. Advantages of Maven + IntelliJ IDEA

Everything is Module:

IntelliJ IDEA draws on the Maven concept and does not adopt the Project concept in Eclipse. Everything is a Module. Whether or not Maven is used, your project is an independent Module. In addition, you can use Maven Module and common Java Module to mix and match. The two can coexist harmoniously.

Multi-module supported:

It can be said that the Maven project structure design is very strict, and you must use the Parent-Child mode in practical applications. Eclipse does not support creating a Sub-Project on a Project, so it cannot be implemented at any time. IntelliJ IDEA can perfectly implement this design, and there will be no problems in both Module attributes and their dependencies.

More convenient lifecycle operations:

IntelliJ IDEA has a separate window to complete Maven operations compared to the actions that Eclipse can put in the right-click menu. You can perform Clean Compile Package Install and other operations on different modules. Each Plug-in operation is clear.

Perfect dependency management:

Maven stores all dependent packages in a directory on the local machine, which is actually separated from the Project itself. IntelliJ IDEA introduces the concept of External Library, where all Maven dependencies are separated from the built-in project Library. In addition, modules are judged intelligently. You do not need Maven Install to update the referenced code.

Dynamic Update:

When Maven-related settings are changed, for example, if you modify the pom dependency and add or delete a Module, IntelliJ IDEA will prompt you to update it. This type of update is actually running Maven, so you are not allowed to manually run Maven Compile for updates, nor will you encounter any inexplicable problems like in Eclipse.

Use IntelliJ IDEA to configure Maven

1. Download Maven

Official Address: http://maven.apache.org/download.cgi

Decompress and create a local repository folder

2. Configure the local repository path


3. Configure maven Environment Variables

 

 

 

 

4. Configure maven in IntelliJ IDEA

Open-File-Settings

5. Create a maven WEB Project

Open-File-New-Project

Click NEXT

 

Click NEXT

 

The added configuration is archetypeCatalog = internal.

Click NEXT

 

Click NEXT

 

Click Finish to create the project.

Click View in the lower right corner

6. maven web template project structure

 

Create a test folder under main, and then create a java test source code folder and a resource test resource folder under this folder.

 

You can also right-click the project and choose Open Module Settings to Open the project configuration page.

7. Configure the dependent jar package

Jar package configuration search

Official Address: http://mvnrepository.com/

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.