Foreword
Today met a demand, it is necessary in the project, the introduction of a SDK package of other projects, the package probably have dozens of types of documents, if all copied into the project, a large amount of work needs to be modified, so consider labeled jar package and introduced.
Introduction
- Need to package the project, and the project needs to be introduced are maven project
- Tools Idea
Packaged jar
- First of all, if you need packaged into a jar, there must be a Main entrance class, if the project is not, remember to create a, which contains the main method as long as you can.
- Then click on the project, choose File menu at the top - Project Structure ...
- Select Artifacts on the left, then click the +
- Main Class Choose your main class to write, and then click OK to
- As shown, the Gogo above and click OK
6. Click on the menu Build --Build Project
You can then find Jar package generated in the root directory of the project classes --artifacts
The introduction of the jar package
If a project requires the additional introduction of the jar package, then, a need for operation
- Create a directory
at the same level src directory create folder of the project lib (this step name at random) - Will just generate good jar package into this folder.
3. The introduction of the project file
, choose File menu at the - Project Structure ...
then click on the right + left side select Modules, as shown.
- Find the jar package under the project directory, import
- Introduced in the pom
attention here and just the new directory to the same directory
<build>
<resources>
<resource> <directory>lib</directory> <targetPath>BOOT-INF/lib/</targetPath> <includes> <include>**/*.jar</include> </includes> </resource> <resource> <directory>src/main/resources</directory> <targetPath>BOOT-INF/classes/</targetPath> </resource> </resources> </build>
The above method can cause problems, preferably with
<dependency>
<groupId>xxx</groupId> <artifactId>xxx</artifactId> <version>v0.1</version> <scope>system</scope> <systemPath>${project.basedir}/lib/xxx.jar</systemPath> </dependency>
Where xx random, package name
6. The end
can then be used in the project introduced in the method of the jar.
Small gifts around and Jane book to my attention
Author: sT Dian
link: https: //www.jianshu.com/p/257dcca702f7
Source: Jane book
Jane book copyright reserved by the authors, are reproduced in any form, please contact the author to obtain authorization and indicate the source.