Are you studying Maven? Are you worried about Maven being difficult to use and having to use? Are you confused about the conflict between Eclipse and Maven? Then I'll tell you a more direct and simple solution: IntelliJ IDEA!
1. What is Maven and why should you use Maven instead of Ant
Maven is simply a project management tool that is considered an alternative or successor to Ant. In fact, Maven's functions are far beyond Ant. It not only provides compiled scripts, but also provides testing, publishing, document generation and other functions throughout the project cycle, and has a unique dependency management method. However, the cost of powerful functions is complex usage methods. The first time using Maven often takes nearly half an hour (domestic internet speed) to download a local dependency library, which will undoubtedly make many developers "retreat when they are difficult." Although widely criticized, an indisputable fact is that Maven gradually replaced Ant, and using Maven has also become a necessary skill for Java developers.
2. IntelliJ IDEA and Eclipse
In the Java world, Eclipse is undoubtedly the king of IDE, and IntelliJ IDEA and NetBeans can only live under the halo of Eclipse. I don't need to say much about the power of Eclipse, but in fact, IntelliJ IDEA is also a very excellent IDE, especially in its intelligence. Its Clone product, ReSharper, aimed at .Net, has been accepted by more and more C# developers. IntelliJ IDEA provides a large number of intelligent rules to assist developers, such as code completion, usage conversion, format prompts, etc. When you get used to it, you will be unable to put down the little light bulb.
3. Reasons to choose Maven + IntelliJ IDEA
The reason I chose IntelliJ IDEA is because Maven+Eclipse is too difficult to use. Eclipse has two Maven plugins m2eclipse and Eclipse IAM. However, due to the contradiction in Eclipse and Maven design, both plugins may not achieve the effect you want. m2eclipse will treat all your types of projects as Maven types, which may be OK for a simple Java project, but it is a disaster for a JEE or WEB project. Eclipse IAM will not change your project type, but the functions it provides are limited to editing and running POM files, and it cannot even manage dependencies. In contrast, if you insist on using Eclipse, I still recommend you to use Eclipse IAM. If Eclipse wants to perfectly support Maven, it may require some changes to the underlying design, whether it is code specifications, project structure specifications and dependency management, there are irreconcilable contradictions. Obviously, IntelliJ IDEA has done so much better in this regard that it is difficult for you to express your dissatisfaction with it.
4. Advantages of Maven + IntelliJ IDEA
Everything is a Module:
IntelliJ IDEA borrows the concept of Maven, and does not adopt the concept of Project in Eclipse, everything is a Module. Whether using Maven or not, your project is a standalone module. And you can mix and match Maven Module and ordinary Java Module, and the two can coexist harmoniously.
Supports Multi-module:
It can be said that Maven's project structure design is very strict, and in real applications you must use the Parent-Child model. Since Eclipse does not support the establishment of Sub-Project on a Project, it cannot be implemented at present in any case. IntelliJ IDEA can perfectly implement this design, and there will be no problems in both the Module attributes and the dependencies between each other.
More convenient life cycle operation:
Compared to the behavior of putting all Eclipse into the right-click menu, IntelliJ IDEA has a separate window to complete the Maven operation. You can perform Clean Compile Package Install and other operations for different Modules, and the operations of each Plug-in are also clear.
Perfect dependency management:
Since Maven will place all dependent packages in a directory on the machine, it is actually separated from Project itself. IntelliJ IDEA introduced the concept of External Library, where all Maven dependencies will be placed, which are distinguished from the library that comes with the project. And there will be intelligent judgments between Modules, and you don’t need Maven Install to update the reference code.
Dynamic update:
Whenever Maven-related settings change, such as modifying the dependencies of pom and adding and removing the Module, IntelliJ IDEA will prompt you to update. This kind of update is actually running Maven, so you are not allowed to manually run Maven Compile to update, nor will you encounter inexplicable problems like Eclipse.
Configuring Maven with IntelliJ IDEA
1. Download Maven
Official address: http://maven.apache.org/download.cgi
Unzip and create a new 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 new maven WEB project
Open -File-New-Project
Click NEXT
Click NEXT
The added configuration is archetypeCatalog=internal
Click NEXT
Click NEXT
After clicking Finish, the project starts creating
Click the bottom right corner to view it
6.maven web template project structure
Also create a new test test folder under main, and then create a new Java test source folder and resource test resource folder under this folder.
You can also right-click the project - select Open Module Settings to open the project configuration page to change
7. Configure dependency 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 to everyone's learning and I hope everyone will support Wulin.com more.