在Eclipse中将项目转换为Maven之后的目录结构 [英] Directory structure after converting a project to maven in eclipse
问题描述
我有一个Java项目,我在Eclipse中使用m2e将其转换为maven.由于我的项目是一个旧项目,因此它没有遵循src/main/java和src/test/java之类的maven目录结构,因此在转换后,以前的目录结构没有改变.
I have a java project, which i converted to maven using m2e from within eclipse. Since my project was a legacy project, it was not following maven directory structure such as src/main/java and src/test/java, so after the conversion the previous directory structure didnt change.
我想知道m2eclipse中是否有一种简便的方法或捷径可以将我的项目重构为maven使用的默认目录结构.
I am wondering if there is an easy way or shortcut within m2eclipse to refactor my project to the default directory structure used by maven.
我尝试在src文件夹中添加一个新的源文件夹,并将文件夹嵌套为src/main/java,但是出现以下错误.
I tried adding a new source folder in my src folder and nest the folders to have src/main/java but I am getting the below error.
请查看快照,因为我没有足够的声誉来发布快照.
Please see the snapshot as i dont have enough reputation to post it.
推荐答案
错误消息指出了问题-您不能嵌套源文件夹,因为包名称没有意义.它很容易解决:
The error message is pointing out the problem - you can't nest source folders, as the package names would make no sense. It is easily fixed:
- 右键单击该项目,然后选择属性"
- 选择 Java构建路径/源
- 删除所有条目
- 添加标准Maven路径(src/main/java,src/main/resources,/src/test/java和src/test/resources)
- Right click the project and select Properties
- Select Java Build Path/Source
- Delete all entries
- Add the standard Maven paths (src/main/java, src/main/resources, /src/test/java and src/test/resources)
退出属性"对话框,项目/清理工具将正确编译所有内容.
Exit the Properties dialog and a Project/clean should compile everything correctly.
这篇关于在Eclipse中将项目转换为Maven之后的目录结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!