[英]Package structure for a Java project?
Whats the best practice for setting up package structures in a Java Web Application?在 Java Web 应用程序中设置包结构的最佳实践是什么?
How would you setup your src, unit test code, etc?您将如何设置 src、单元测试代码等?
You could follow maven's standard project layout .您可以遵循 maven 的标准项目布局。 You don't have to actually use maven, but it would make the transition easier in the future (if necessary).
您不必实际使用 maven,但它会使将来的转换更容易(如有必要)。 Plus, other developers will be used to seeing that layout, since many open source projects are layed out this way,
另外,其他开发人员会习惯于看到这种布局,因为许多开源项目都是这样布局的,
There are a few existing resources you might check:您可能会检查一些现有资源:
For what it's worth, my own personal guidelines that I tend to use are as follows:就其价值而言,我倾向于使用的个人指导方针如下:
A couple of other points:其他几点:
I would suggest creating your package structure by feature, and not by the implementation layer.我建议按功能创建包结构,而不是按实现层。 A good write up on this is Java practices: Package by feature, not layer
对此的一篇很好的文章是Java 实践:按功能打包,而不是按层
The way I usually organise is
- src
- main
- java
- groovy
- resources
- test
- java
- groovy
- lib
- build
- test
- reports
- classes
- doc
I usually like to have the following:我通常喜欢以下内容:
These may be considered unconventional, but I find it to be a very nice way to organize things.这些可能被认为是非常规的,但我发现这是一种非常好的组织方式。
The way i usually have my hierarchy of folder-我通常拥有文件夹层次结构的方式-
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.