How to compile a Maven project using intellij idea

Source: Internet
Author: User

 

 

Make up the requirements of the latest effect project, and learn to compile the project on idea. As a newbie, it is normal to encounter problems. The important thing is to solve them and get new skills.

 

Anyone who has compiled Maven projects should know how to compile Maven projects in eclipse: Right-click the project --> Run as --> Maven install. Simple and clear.

 

However, on idea, the maven project has its own window, And the maven project directory in the window is different from that in the project window. I will share my experience here.

 

1. Open the maven project window: toolbar --> help --> Find action. In the pop-up window, enter Maven projects in the text box.

2. In the open Maven project window, click yourproject-> lifecycle-> package-> RUN Maven build to run the package. The generated war is in the target directory of the project by default.

 

How does idea execute Maven commands?

Click terminal in the lower left corner of the idea main interface and enter the command you want to execute.

Exec Maven plugin comprehensive parsing and use example

1. Why is exec used?


Current projects often rely on a large number of jar packages. Unlike war package projects, for local Java applications packaged as jar packages, starting with a Java command will be a very tedious task. The reason is very simple. Too many dependencies make the parameter-classpath abnormal. Therefore, when releasing an application, two methods are generally used to start the application: one is to package the project and all its dependent jar packages into an independent jar package (in Maven, there are two plug-ins assemly and shade for this purpose ); another method is to compile a run. the bat file contains a Java command to start the application. Obviously, the classpath of this command must contain all dependent jar packages. However, for applications that are still in the development stage, the first method needs to decompress all the jar packages and re-package them. This is very time-consuming, especially when the project is very large. The problem with the second method is that for projects in the development stage, you often need to introduce or upgrade the jar package, which requires frequent modification of the run. BAT file. In fact, for projects managed by Maven, you can use Maven to obtain the classpath of the project and simplify the startup command of the application. This is the primary motivation for the maven plug-in Exec to be designed. The biggest advantage of using exec over using Java commands to start an application is that you don't need to worry about-classpath any more.

2. What is the difference between Exec: exec and Exec: Java?

Exec is mainly composed of two goal: Exec: exec and Exec: Java. How should you choose? First, you must remember that exec: exec is always greater and more flexible than Exec: Java, which will be shown in the following examples, the main difference between the two is that in thread management: Exec: exec always starts a new thread and exits from the VM (closes the application) when only the daemon thread is left ). For Exec: Java, when all non-daemon threads end, the daemon thread will be joine or interrupt, and the program will not be closed. However, for general users, this difference is not important. Generally, if your project is very easy to start and you do not need to set JVM parameters, system attributes, and command line parameters, Exec: Java is used, you only need to specify mainclass, and everything will be OK.

 


---------------------

How to compile a Maven project using intellij idea

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.