หน้านี้ยังไม่พร้อมใช้งานในภาษาท้องถิ่นของคุณ เรากำลังพยายามอย่างหนักเพื่อเพิ่มเวอร์ชันภาษาอื่น ๆ เพิ่มเติม ขอบคุณสำหรับการสนับสนุนเสมอมา

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ CodeArts Build/ FAQs/ Maven Builds/ How Do I Deal With the Missing Package or Symbol?

How Do I Deal With the Missing Package or Symbol?

Updated on 2024-10-10 GMT+08:00

Symptoms

When Maven build task is executed, an error message is displayed, indicating that the package or symbol cannot be found. For example:

com/xxx/xxx/configserver/encryptor/xxx.java:[11,40] package com.sun.jersey.api.client.config does not exist

Cause Analysis

According to the log, the project references the com.sun.jersey.api.client.config package. However, the package cannot be found in the project or all parsed dependency packages. The problem lies either in the code or the environment/component:

Dependency Package Conflict

Sometimes, multiple versions of the same dependency exist in a project due to misoperation or third-party dependency imports. This will make the used version different from the required version, and as a result the specified package cannot be found. To solve this problem, perform the following steps:

  1. Use either of the following methods to check the version of the dependency package:

    1. Maven resolves dependency conflicts with the following strategies:
      • Nearest wins: For example, when building A, two dependencies exist: A > B > C > X 1.0 and A > D > X 2.0. Then X 2.0 will be used because the path from A to X through D is shorter.
      • First declaration wins: If two dependency versions are at the same depth, the first declaration wins.

    2. Use the Maven Dependency Plugin and run the mvn dependency:tree command in the build task.

  2. If the build fails because the dependency version is not the required version, import the required dependency at the outermost layer of the POM and try again.

    <dependencies>
    	<dependency>
    		<groupId></groupId>
    		<artifactId></artifactId>
    		<version></version>
    	</dependency>
    </dependencies>

Incorrect Dependency Range

In Maven, the dependency scope attribute specifies the visibility of a dependency. If the dependency scope is incorrectly specified, the dependency will be invalid during compilation. If the package in the dependency is used in the main code of the project, a compilation error will occur. Perform the following steps to solve the problem.

  1. Run the mvn dependency:tree command to view the dependency and dependency scope used by the project.
  2. Compare the dependency scope and the location where the dependency is used in the project.

    If the package in the dependency is used in the main code and the dependency must be valid during builds, the dependency scope must be one of the following options:

    • compile
    • provided
    • system: The location of the dependency file is specified in systemPath. The package must exist in the specified directory.

Dependency Package Uploaded Using GAV

  • When uploading a dependency package to self-hosted repos using the groupId, artifactId, and version (GAV), you only need to upload the JAR package. The POM file will be generated automatically, but only contains the identifiers of the dependency. The original <dependencies> details will be lost.
  • For example, assume that you use dependency A, which is built through project A, for building project D. Dependency A contains a third-party dependency, B. The dependency relationships are: D > A > B. When parsing dependency A, Maven will not be able to identify dependency B. As a result, project D cannot find contents in dependency B. In this case, perform the following steps:
  1. Check the dependency tree of project D and check whether the missing content is introduced by the POM file of project A. If yes, go to the next step. If no, try other solutions.
  2. Download the POM file of dependency A from the self-hosted repo of CodeArts Artifact and compare it with the POM file of project A. If the downloaded file does not contain the content introduced by B, go to the next step. Otherwise, try other solutions.
  3. Update the version of dependency A and upload it again using either of the following methods:

    • Build project A in CodeArts Build. Run the deploy command to upload dependency A to the private Maven repository. You can use the pipeline for automation.
    • Upload dependency A to the private Maven repository again. This time, upload the JAR packages and POM files separately.

  4. Build project D again.

Damaged Dependency Package

If the dependency package is damaged, some files in the package may be missing. As a result, the required dependency package can be found during a build, but the CLASS file or package cannot be found. The solution varies by the package type:

  • Third-party dependency package: Contact technical support.
  • Self-developed package (manually uploaded to the private Maven repository): Perform the following procedure.
    1. Download the dependency package from the private Maven repository.
    2. Decompress the package and check whether the content is normal.
    3. If the content of the dependency package is abnormal, perform either of the following steps:
      • If the package is provided by a third party and manually uploaded to the private Maven repository, ensure that the package file is correct and upload the package again. (Note that both the POM and JAR files must be uploaded.)
      • If the dependency package is built by yourself (on premises or in the cloud) and the code is correct, check whether the JAR package is incomplete because multiple build tasks run in parallel.

เราใช้คุกกี้เพื่อปรับปรุงไซต์และประสบการณ์การใช้ของคุณ การเรียกดูเว็บไซต์ของเราต่อแสดงว่าคุณยอมรับนโยบายคุกกี้ของเรา เรียนรู้เพิ่มเติม

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback