Resolving Dependency Missing and Dependency Conflict
Dependency missing and dependency conflict are commonly encountered in Java development or during SDK integration. If error message "ClassNotFoundException" or "NoClassDefFoundError" is reported during application compilation and running, check whether this is a dependency-triggered problem. If yes, perform the following steps to locate and rectify the fault.
Dependency Missing
When the OBS SDK is imported using a package management plug-in, for example, Maven, the plug-in automatically downloads required dependencies. In other cases, you need to download the dependencies and add them to the project. The following table lists the third-party components (including their versions) that the latest SDK depends on.
|
Dependency |
Version |
Function |
|---|---|---|
|
okhttp |
3.14.9 |
Used to send HTTP requests. |
|
okio |
1.17.5 |
Component of OkHttp |
|
java-xmlbuilder |
1.3 |
Used to construct and parse XML files. |
|
jackson-core |
2.11.1 |
Used to construct and parse JSON files. |
|
jackson-databind |
2.11.1 |
Component of jackson-core |
|
jackson-annotations |
2.11.1 |
Component of jackson-core |
For details about the third-party dependencies of other SDK versions, see the SDK compile dependencies in the Maven central repository.
Dependency Conflict
If your project has multiple versions of OBS Java SDK packages or third-party dependencies, dependency conflicts may occur. If there are SDKs of earlier versions, delete them and use the latest version. If there are multiple versions of third-party dependencies, replace the conflict ones with the versions required by the SDK.
Using a Bundle Package
If a variety of or multiple versions of third-party dependencies in your project cannot be deleted, you can use the SDK bundle. The bundle package contains all third-party dependencies except log4j and can be directly used. The bundle package is larger than a common SDK package. To use an SDK bundle, ensure that there is enough space. The Maven configuration of a bundle package is as follows:
<dependency>
<groupId>com.huaweicloud</groupId>
<artifactId>esdk-obs-java-bundle</artifactId>
<version>[3.21.4,)</version>
</dependency>
Last Article: Methods
Next Article: Other Notable Issues
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.