Cases
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
Solutions
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:
- Update project manually_ Solution of too large jar package in springboot
- How to turn your project into a jar package in idea
- Maven’s jar package conflict; Maven’s introduction
- Zip to decompress the jar package, like the add file in the jar package
- How to select the jar package version for Maven package when the jar package versions referenced by multiple modules are inconsistent
- Research on Maven management of Java project pom.xml The jar package error is reported, but the project is running normally
- The spring boot project directly replaces the referenced jar package
- Brief introduction of cmake generating all in vs Project_ BUILD、INSTALL、ZERO_ Check function!!
- Idea Maven project uses package to package and report error (package does not exist)
- Failed to get the resources path in the jar package, reporting an error null pointer
- [Solved] Ktolin Android Project Compile Error: w: Runtime JAR files in the classpath should have the same version. These file
- When Maven hits the jar package, an error is reported when executing install, and the symbol cannot be found in a line
- [solution] the resource file cannot be found in the jar package of Java
- [Solved] Error in registering Eureka for spring cloud micro service: classnotfoundexception: org.apache.http.conn.scheme.schemeregistry
- Java project cannot import entity class package and service package, controller layer reports error, fix project setup is OK
- Does the version of idea2020.1 import mybayis jar package or report an error? Error: (4,28) Java: package org.apache.ibatis.io does not exist
- Mybatis idea environment integration jar package
- The jar package download of Maven project appears (could not transfer artifact. Org mybatis:mybatis )
- Error in the project tag in the POM file of Maven project: failure to transfer
- Maven compilation error: package does not exist jar package does not exist