简体   繁体   English

声明的软件包与apache-commons的预期软件包不匹配

[英]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. 我正在尝试将apache-commons添加到我的新项目中,但是在导入源代码后出现软件包问题。

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. Java中的软件包会转换为文件夹层次结构,包括源文件和已编译的类文件。 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 . 预期包含软件包org.apache.commons.math 源文件夹将以org/apache/commons/math/类的结构包含文件,其中源文件夹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 . 拥有预期的src.main.java.org.apache.commons.math包意味着src/main/java 源文件夹中,而不是被设置 源文件夹 Open your project's Properties dialog, go to the Java Build Path page, and correct the contents of the Source tab. 打开项目的“ 属性”对话框,转到“ Java构建路径”页面,然后更正“ 源”选项卡的内容。 If you're using Maven or another tool to compile your sources instead, fix that configuration directly. 如果您使用Maven或其他工具来编译源代码,请直接修复该配置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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