Maven project from Eclipse to intellij idea summary

table of Contents

One environment migration

1.mvn command

2. Import the project in intellij idea

Two, Maven project jar package


There is a code generation tool project that is an Eclipse project. As IntelliJ idea is much easier to use than Eclipse, I have not succeeded in transferring it once, and today I suddenly wanted to convert this project into an IntelliJ idea project. When I was in a good mood, everything went smoothly, and now it has been successfully completed. Summarize the operation process and the problems encountered

One environment migration

1.mvn command

You need to enter the directory containing pom.xml in the command line window, execute the following command, and the war package will be automatically generated.

gMacBook-Pro:project j1$ mvn clean package

2. Import the project in intellij idea

The following steps are the basic steps to import a maven project into IntelliJ idea:

  • (1)import Project

  • (2) Find the directory where pom.xml is located, click confirm, and enter the following interface:

  • (3) Select Maven, click next all the way to import the project into IntelliJ idea

After completing the above operations, find the main() function of the project and run it.

Two, Maven project jar package

Because the project is a tool used to generate part of the code, the project needs to be packaged into a jar package at the end, and the code generation can be completed by directly running the jar later. Then you need to be able to use intellij idea to package the jar. Some problems were encountered in this process. Summarize and record.

Because the project itself was packaged through maven-shade-plugin before, you can directly use the visual interface of intellij idea to operate, that is, the operation interface as shown in the figure:

You only need to execute clean, compile, package, and install in sequence to package the jar package. In this process, the following problems have been encountered:

--- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ generate-code --- [INFO] No sources to compile

This problem is actually caused by the inconsistency of the jdk version in the project, so you need to check the following places involving jdk configuration one by one, and then keep the same:

  • (1) Configuration in the project pom file

  • (2) jdk configuration under Preferences

  • (3) Project, Modules and jdk configuration in SDKs in Project Structure

Keep the configurations of the above several jdk consistent, and you can succeed after executing compile, package, and install.

Of course, there are other ways to package the jar package. This article does not summarize.

Guess you like

Origin blog.csdn.net/nihaomabmt/article/details/112306383