Netbeans在非标准Maven项目布局中找不到源 [英] Netbeans can't find sources in non-standard maven project layout

查看:122
本文介绍了Netbeans在非标准Maven项目布局中找不到源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Netbeans 8.1来处理具有非标准项目结构的Maven项目.在我的项目中,我的来源在 src/foo 下,而不是在 src/main/java 下.要打开我的项目,请点击菜单中的文件> 打开项目... .然后,在打开的文件浏览器中导航到我的项目.然后,我选择我的项目并单击 Open .当我的项目在Netbeans的 Projects 选项卡中打开时,它不包含任何源包.它仅显示一个标记为 Dependencies 的文件夹和一个标记为 Project Files 的文件夹.

I'm trying to use Netbeans 8.1 to work on a Maven project with a non-standard project structure. In my project, my sources are under src/foo instead of src/main/java. To open my project, I click File > Open Project... in the menu. Then I navigate to my project in the file browser that opens. Then I select my project and click Open. When my project opens in the Netbeans Projects tab, it does not contain any source packages. It only shows a folder labeled Dependencies and a folder labeled Project Files.

我试图在项目属性中更改源文件夹的位置以解决此问题.我右键单击该项目,单击属性",然后单击左侧菜单中的源".然后,我尝试编辑源文件夹值,但是该值不可编辑.值得注意的是,对于ant项目,我可以在项目属性中添加源,但是对于Maven来说,这似乎是不可能的.

I've tried changing the location of the source folder in the project properties to fix this. I right-click on the project, click Properties, and then click Sources in the menu on the left. Then I try to edit the Source Folder value, but the value isn't editable. It's worth noting that for ant projects, I can add sources in the project properties, but for Maven this doesn't seem possible.

推荐答案

您的maven项目实际上是否正确构建? IDE将从您的POM模型中提取源位置.例如

Does your maven project actually build correctly? The IDE will pull the source location from your POM model. Eg.

<project>
  <build>
    <sourceDirectory>${project.basedir}/src/foo</sourceDirectory>
  </build>

这篇关于Netbeans在非标准Maven项目布局中找不到源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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