在Eclipse中将项目转换为Maven之后的目录结构 [英] Directory structure after converting a project to maven in eclipse

查看:286
本文介绍了在Eclipse中将项目转换为Maven之后的目录结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆