Chuan package packaging idea

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

  1. 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.
 
image.png
  1. Then click on the project, choose File menu at the top - Project Structure ...
 
image.png
  1. Select Artifacts on the left, then click the +
 
image.png
 
image.png
  1. Main Class Choose your main class to write, and then click OK to
 
image.png
  1. As shown, the Gogo above and click OK
 
image.png

6. Click on the menu Build --Build Project

 
image.png

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

  1. Create a directory
    at the same level src directory create folder of the project lib (this step name at random)
  2. 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.
 
image.png
 
image.png
  1. Find the jar package under the project directory, import
 
image.png
  1. 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.

Guess you like

Origin www.cnblogs.com/jeasonit/p/11327705.html