问题描述
我导入外部项目时遇到问题。我将文件 - >导入... - >现有项目导入Workspace,选择项目所在的文件夹,并导入所有内容 - 但项目的包名似乎不是Eclipse所期望的。包名称都有一个前缀:
I have a problem importing an external project. I go File -> Import... -> Existing Projects into Workspace, choose the folder where the project is located and everything is imported - but the package names of the project don't seem to be what Eclipse expects. The package names all have a prefix:
prefix.packagename1
prefix.packagename2
等。
但是Eclipse希望
But Eclipse expects
src.prefix1.prefix.packagename1
src.prefix1.prefix.packagename2
等。因为目录是src / prefix1 / prefix / package1
etc. because the directory is src/prefix1/prefix/package1
我真的不想用外部代码搞乱。如何让Eclipse忽略目录src / prefix1?或者还有什么可以做的?
I don't really want to mess around with external code. How do I tell Eclipse to ignore the directory "src/prefix1"? Or what else can I do?
推荐答案
只需进入构建路径,源路径为 src / prefix1
而不是 src
。
Just go into the build path and the source path to be src/prefix1
instead of src
.
可能最容易右键单击在 src
目录下,选择构建路径/从构建路径删除,然后找到 src / prefix1
目录,右键单击并选择构建路径/用作源文件夹。
It may be easiest to right-click on the src
directory and select "Build Path / Remove from build path", then find the src/prefix1
directory, right click and select "Build Path / Use as source folder".
这篇关于Eclipse:声明的包与预期的包不匹配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!