Maven directory structure

只愿长相守 提交于 2019-12-10 02:25:17

问题


I'm new to Maven and I've been reading all morning tutorials (amazing tool).

This new Java project I started looking at however doesn't use the default directory structure. Instead of src/main/java for sources it uses something like src/org/myapp.

When I run mvn package on the project (where pom.xml is located) I get a message saying that no Sources have been compiled because it's not able to find them (the source path being different).

Is there a way to specify your own sources path in Maven?


回答1:


Add sourceDirectory to the build tag in the pom file.

<build>
    ...
 <sourceDirectory>src</sourceDirectory>
    ...
</build>

Here is the relevant section in the maven docs.




回答2:


In theory, you can use a non-standard directory structure for your Maven project. In practice, you may find that various Maven plugins and IDE integrations won't work properly. So I'd advise that you reorganize your project directory structure to be what Maven expects ... before you get lots of version control history and other stuff that will make reorganization more painful.




回答3:


How did you create the project? The idea way to create a new maven project is: mvn archetype:create and then follow the instructions.

Read this for more details

Update to extend by answer based on the URL:

mvn archetype:create -DgroupId=[your project's group id] -DartifactId=[your project's artifact id]


来源:https://stackoverflow.com/questions/4040888/maven-directory-structure

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!