在Eclipse中自动添加导入时错误的包名称 [英] Wrong package name when using automatically added imports in Eclipse
问题描述
import src.main.java.com.mycompany;
而要导入的真实包是 com.mycompany
。
这必须是Eclipse中的一些配置来解决这个问题,但我很困惑。不过,这个问题很烦人。
编辑:
我忘了提到Eclipse文件是使用 mvn eclipse:eclipse
命令。
在Eclipse项目下似乎正确配置。它的源文件夹设置如下:
- src / test / java
- src / test / resources
- src / main / java
- src / main / resources
除了我按 CTRL + SHIFT + M 键
$ b的情况下,Eclipse下的所有内容都可以正常工作$ bJava项目的标准源文件夹是
./ src
对于导入的maven项目,只需从源文件夹列表中删除该文件夹即可建立路径设计者正确的源文件夹是
./ src / main / java
I have several Maven projects converted into one Eclipse workspace. When I edit the code under Eclipse, I sometimes use CTRL+SHIFT+M combination of keys to automatically add imports to the classes from a project in my workspace. But somehow they are added like this:
import src.main.java.com.mycompany;
while to real package I wanted to import is com.mycompany
.
This has to be some configuration in Eclipse to fix this but I'm confused. However, this issue is very annoying.
EDIT:
I've forgotten to mention that Eclipse files were generated using mvn eclipse:eclipse
command.
Under Eclipse project seems to be configured properly. Its source folders set like this:
- src/test/java
- src/test/resources
- src/main/java
- src/main/resources
And everything under Eclipse works properly except the situation when I press CTRL+SHIFT+M keys
The standard source folder for Java projects is
./src
For imported maven projects, simply remove this folder from the list of source folders at the build path settigs. The correct source folder is
./src/main/java
这篇关于在Eclipse中自动添加导入时错误的包名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!