【发布时间】:2016-09-13 16:26:02
【问题描述】:
在我发帖之前我已经做了很多研究,我想就我是否应该创建一个新的 Spring Boot 项目,并使用多 maven 结构......或者,我应该转换我当前的 Maven 多模块 Spring MVC RESTful 项目到 Spring Boot。
我们想要一个 Spring Boot 项目,因为那时使用 Docker 可能更容易。 我们真的希望在 Docker 容器中使用这个 Spring MVC RESTful 后端,但我们发现的所有示例都涉及使用 Spring Boot 和 Docker。
所以,项目的结构是这样的:
parent pom.xml
Entity
- basic Spring Project with Hibernate entities
- has a myproject-entity-context.xml as the Spring application context
- has the database and transactions configured in the context
- translates to a JAR file
- has its own pom.xml and can be built independently
DAO
- basic Spring project with Data Access crud Objects
- has it's own myproject-dao-context.xml file
- inherits from the myproject-entity-context.xml
- pulls in the myproject-entity.jar file in the pom.xml
- translates to a JAR file
- has its own pom.xml so this DAO can be built provided the entity.jar is built
- obviously this layer does all the database work
- very much init tested
Service (Business Services)
- basic Spring project with Transactional Business Services
- one business service can call mutltiple DAO's
- has it's own myproject-service-context.xml file
- inherits from the myproject-dao-context.xml
- pulls in the myproject-dao.jar file in the pom.xml
- translates to a JAR file
- has its own pom.xml so this Service can be built, provided the DAO is built first
- obviously this layer does all the business services work
- very much init tested
Web-Services
- basic Spring Web-App project that compiles to WAR
- has all the Controllers which stores all the endpoints
- has it's own myproject-ws-context.xml file
- inherits from the myproject-service-context.xml
- pulls in the myproject-service.jar file in the pom.xml
- translates to a WAR file
- has its own pom.xml so these Web-Services can be built, provided the myproject-service.JAR is built first
- obviously this layer does all RESTful end-points which call 1 business service
- very much init tested
我们的 Spring MVC RESTful 后端也使用 Spring Env Profiles,我们有一个读取外部 env.properties 文件的配置文件。
我们还使用 Spring Security 4.0 来保护 RESTful 端点。
我们想把这个应用程序放在一个 Docker 容器中吗?但是所有文档都适用于 Spring Boot,因此我们可以将 Spring Boot 添加到这个现有项目中,但我不知道如何......或者从一个新的 Spring Boot 项目开始,然后使用我现有的代码可能会更容易并将其放入新的 Spring Boot 项目中。我不知道哪个更容易,哪个更难?
我们甚至需要 Spring Boot 来将此应用程序放入 Docker 容器中吗?
任何帮助将不胜感激,如果需要,我可以根据需要在此处添加更多信息。
谢谢!
【问题讨论】:
标签: maven spring-mvc spring-security docker spring-boot