简体   繁体   中英

The declared package does not match the expected package for apache-commons

I'm trying to add apache-commons to my fresh project but I got problems with packages after importing the source.

The declared package "org.apache.commons.math" does not match
the expected package "src.main.java.org.apache.commons.math"

What can I do?

Packages in Java translate into a folder hierarchy, both for the source files and the compiled class files. A Source Folder expected to contain the package org.apache.commons.math will contain files in a structure like org/apache/commons/math/ where the Source Folder is the direct parent of org . Having an expected package of src.main.java.org.apache.commons.math means that src/main/java is in a Source Folder rather that being set as a Source Folder . Open your project's Properties dialog, go to the Java Build Path page, and correct the contents of the Source tab. If you're using Maven or another tool to compile your sources instead, fix that configuration directly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM