开发者

What is an ideal way to organize a Spring 3 web application and its components?

开发者 https://www.devze.com 2023-02-16 02:11 出处:网络
I\'m developing an application which has two main \'parts\' to it... The public facing website The RESTful API for the mobile application.

I'm developing an application which has two main 'parts' to it...

  1. The public facing website
  2. The RESTful API for the mobile application.

I'm developing the application wi开发者_JAVA技巧th Spring 3 using Spring Tool Suite as my IDE. At first I thought that the API would be part of the same project as the public website. But then I tried to mix basic auth in with my form based auth for the public website things started to get a little confusing with Spring Security.

So I thought it might be best to develop the API as a separate project and share my domain objects, services and DAOs between the API and website projects. My question(s) now are:

  1. Is this a dumb idea?
  2. Should create a 'core' project with the shared domain objects, services, etc?
  3. Should I use Maven and add the 'core' project as a dependency for the API and website projects?
  4. Is there a better way to do all this?


It very much depends on what your needs are. I am currently working on a fairly large GWT application (using SpringSource Toolsuite and Maven).

We make extensive use of Maven modules and profiles. It can get a bit messy at times but it does enforce separation, which I think is generally a good thing.

I would say, if your front end and back end code are going to be completely separate, it might not be a bad idea to create them as separate modules. You can then set up your Spring Security as you wish for each project etc.

So, to summarise, I would say modular is a good way to go, but do investigate Maven modules as this may help you with dependencies.


I have the same specs as you

  1. The public facing website
  2. The RESTful API for the mobile application.

I have to separate web projects one for my RESTFULL services based on JSON and a database dependency. For my frontend project I don't have a dependency to the database but only to my restfull services.

With this strategy it is possible to use the same codebase for webprojects and mobile applications.

0

精彩评论

暂无评论...
验证码 换一张
取 消