naiquevin
naiquevin

Reputation: 7796

Organizing a Spring-mvc project with many sub applications

I am starting with a project in Spring-mvc which basically is made up of 3 parts

1) Frontend

2) Backend (admin)

3) Web service

What would be best way to organize these parts so that I can reuse the domain and DAO layer objects wherever I can and at the same time keep the packages separate (so as to avoid class names such as FrontendCategoryController and BackendCategoryController in the same package) ?

Also would it be a good idea to have common config and the pom.xml file for all these parts ?

As of now I have started with the project structure generated by maven as per the webapp archetype

Edit:

One way I am thinking of doing this is -

myapp
  -- src
      -- main
           --java
           --resources
      -- backend
           --java
           -- resources
      -- webservice
           -- java 
           -- resources

in all java directories, the package names will be same

Would this be a correct approach

Thanks

Upvotes: 1

Views: 1652

Answers (1)

axtavt
axtavt

Reputation: 242686

First of all, depicted approach that misuses Maven directory structure looks really bad.

You say that you want to avoid long class names such as FrontendCategoryController and BackendCategoryController. It looks like your design violates "Package by feature, not layer" rule. You can create separate packages for your subapplications, so that long class names wouldn't be needed. Common classes used by all subapplications can be placed in yet another package.

Alternative approach would be to create separate Maven projects for different subapplications, but it looks like you don't want it.

Upvotes: 4

Related Questions