Maven uses IDEA's own tools to package, and at the same time import the jar package under lib, double-click the jar package to run it directly

foreword

Using IDEA's own packaging tool, you can package the third-party jar package you introduced (jar package under lib, not in the pom file) into the jar.

Artifacts is a concept in maven, indicating how to package a certain module, such as war exploded, war, jar, ear, etc.; Artifacts, its function
is to integrate compiled java files, resource files, etc., there are Different integration methods, such as war, jar, war exploded, etc.,

Artifacts also has an Output Directory: while the output directory in Artifacts is related to the container, when the container is running,

1. Copy the classes file of the first two that work (individual configuration is preferred) to the WEB-INF of the Artifacts configuration directory, 2. Then copy the
resource file directory in the Facet of the Module to the Artifacts directory,
3. Then copy the jar package under lib to WEB-INF, and then the project can be started.

1.1 Create Artifacts

The shortcut key (Ctrl+Alt+Shift+S) opens the Project Structure of the project. Created in Artifacts
insert image description here

Configure the main class Main Class. When running the packaged jar project, here is the entry.
insert image description here

Created artifacts
insert image description here

Special Note : Here you can use "+" or "-" to select those third-party jar files that need to be entered into artifacts, as shown in the figure:

insert image description here

1.2 Packaging Artifacts

Select Build in the menu bar, select Build Artifacts

insert image description here
In the last window, click Build
insert image description here

position after packing.
insert image description here

Open a command window and enter the root directory where the jar package is located. (Open as an administrator)
Execute the command java -jar to type out the complete jar package name.

java -jar small_tools.jar 

insert image description here

1.3 Double-click the jar package directly

insert image description here

Data reference:
Contains multiple packaging methods
IntelliJ IDEA itself and maven project packaging methods (single module)

Guess you like

Origin blog.csdn.net/weixin_43304253/article/details/131568459