The introduction of third-party jar package in mavn project results in classnotfoundexception


I have a maven built project. There are dependencies between the project modules. I need to use a local jar package, which cannot be configured pom.xml The file is automatically downloaded from the remote warehouse, so I directly import the jar package to one of the projects without passing the pom.xml As a result, other modules that depend on the module cannot reference the jar, and classnotfoundexception appears tion

In this project, there are the following dependencies between modules:

The project needs to introduce fastdfs_ client_ V1.20.jar package is used to operate the fastdfs distributed file system. Both service and controller are involved in the operation. So now we want to put the operation tool class of fastdfs in the common module for sharing. But now the common module directly uses fastdfs_ client_ If v1.20.jar is imported through lib, because this method is not built through maven, so service In other words, even if the tool class is placed in the common module, neither the service nor the web module can access the tool class and import the corresponding package. When running the whole web project and uploading the file to the fastdfs system, classnotfoundexception will appear, unless both the service and the web module can inherit Fastdfs in common module_ client_ The jar package v1.20.jar


1. Find the specific location of the package

2. Open the CMD and enter the directory of the third party jar package

3. Run the command to build the jar package manually

mvn install:install-file -Dfile=D:\Users\10856214\workspace-template\fastDfs\lib\fastdfs_client_v1.20.jar -DgroupId=fastdfs_client -DartifactId=fastdfs_client -Dversion=1.20 -Dpackaging=jar -DgeneratePom=true

4. Check the local warehouse to see if the jar package has been added to the local warehouse folder

5. Give the jar package to Maven for management and add it to pom.xml in

<span style="white-space:pre">		</span><dependency>
<span style="white-space:pre">			</span><groupId>fastdfs_client</groupId>
<span style="white-space:pre">			</span><artifactId>fastdfs_client</artifactId>
<span style="white-space:pre">			</span><version>1.20</version>
<span style="white-space:pre">		</span></dependency>

6. Restart Maven install common module to see if the service and web modules have been imported into the common module’s tool classes

Read More: