Search code examples
javahibernatedirectory-structure

Project Structure for Hibernate Struts project?


I started developing one Blog Website based on Hibernate and Struts. I was wondering how to maintain the structure of the directory and files. That is, the presentation, hibernate DB access layers, controllers and business layers. Any suggestion?

Regards Swar


Solution

  • I don't think there is a single answer to this question but here is mine.

    For a simple project without strong modularity requirements, I would use a single project.

    For the project layout itself, I follow the Maven standard directory layout. For a webapp, this typically means something like this:

    .
    └── src
        ├── main
        │   ├── java            - Application/Library sources
        │   ├── resources       - Application/Library resources
        │   └── webapp          - Web application sources
        │       └── WEB-INF
        └── test
            ├── java            - Test sources
            └── resources       - Test resources
    

    And I would use java packaging naming conventions to organize classes from the various layers:

    • com.acme.<app>.<module>.web.action for struts actions
    • com.acme.<app>.<module>.web.forms : for struts form beans
    • com.acme.<app>.<module>.service : for business services interfaces and implementations
    • com.acme.<app>.<module>.bo : for the business objects
    • com.acme.<app>.<module>.dao : for DAO interfaces
    • com.acme.<app>.<module>.dao.hib : for Hibernate implementations of the DAOs

    But for a small application, I would just skip the functional <module> subdivision.

    Related questions