Configure-Convert a Spring app to Spring Boot app











up vote
0
down vote

favorite












I have a pretty traditional classic Spring web-app that serves up RESTful services as a multi-maven module project.



There are a lot of great web-sites out there that I have found, and have some have good examples. I can make something work, but that doesn't mean it is a standard approach. So, the reason I am asking here, is for what a standard Spring Boot should be for a RESTful app. Is the layout I am using fairly normal and/or standard, or is it crazy. What is the normal standard layout for a Spring Boot multi-maven module.



Let me lay this out:



parent-maven-project
pom.xml - repos, properties, modules

entity-module - translates to JAR, all hibernate entities
myapp-entity-context.xml - beans for mostly the dbconn/session/trx
pom.xml - points to parent-maven-project has dependencies

dao-module - translates to jar, all db CRUD and unit tests
- imports entity-module.jar
myapp-dao-context.xml
this xml imports myapp-entity-context.xml
also has any other bean definitions needed for this module
pom.xml - points to parent-maven-project has dependencies

service-module - translates to jar, contains business logic
- imports dao-module.jar
myapp-service-context.xml
this xml imports myapp-dao-context.xml
also has any other bean definitions needed for this module
pom.xml - points to parent-maven-project has dependencies

ws-module - translates to war, contains RESTful endpoints
- imports service-module.jar
myapp-ws-context.xml
this xml imports myapp-service-context.xml
also has any other bean definitions needed for this module
pom.xml - points to parent-maven-project has dependencies
webapp
WEB-INF
spring-security.xml
springmvc-serlet.xml
web.xml


Some people may like what I have done by separating out the modules, and seeing how the WAR is pulling the service-module.jar which has the dao-module.jar which has the entity-module.jar, and some may not like it.



You can see the 'myapp-ws-context.xml' has imported the 'myapp-service-context.xml' which in turn has imported the 'myapp-dao-context.xml' which has in turn imported the fist 'myapp-entity-context.xml'. Some people may like this, and other people may feel like this is an abomination.



I will say, that in this order, if I compile my modules:

entity, dao, service, ws
then everything compiles correctly, and all unit tests run correctly, and the app runs great! This is the system that I have come up with over the years, and it looks very similar to any Spring apps I see now.



With all this being laid out, I am looking at the 'standard' way of creating a multi-maven module Spring Boot app. So, here is what I know, and here is what I have questions on:



1) I know all the myapp-xxx-context.xml files should be converted to Java Config classes



2) I think that the spring-secutity.xml, the web.xml, and springmvc-servlet can all be converted to Java Config classes as well????? For all I know, these three xml files can be put in one Java Config class.



The overall reason for modules is that I really want to encapsulate what I need for these modules in the pom.xml dependencies, and in the spring application context files.



Here is a layout that I think I am going to need.



parent-maven-project
pom.xml - repos, properties, modules
- parent is spring boot start project

app-module - Beginning Spring Boot App, translates to jar
pom.xml - points to parent-maven-project has dependencies
src/main/java/com/myapp/AppConfiguration.java

entity-module - translates to JAR, all hibernate entities
pom.xml - points to parent-maven-project has dependencies
src/main/java/com/myapp/EntityConfiguration.java
- @Import AppConfiguration.java


dao-module - translates to jar, all db CRUD and unit tests
- imports entity-module.jar
pom.xml - points to parent-maven-project has dependencies
src/main/java/com/myapp/DaoConfiguration.java
- @Import EntityConfiguration.java

service-module - translates to jar, contains business logic
- imports dao-module.jar
pom.xml - points to parent-maven-project has dependencies
src/main/java/com/myapp/ServiceConfiguration.java
- @Import DaoConfiguration.java

ws-module - translates to war, contains RESTful endpoints
- imports service-module.jar
pom.xml - points to parent-maven-project has dependencies
src/main/java/com/myapp/WebServiceConfiguration.java
- @Import ServiceConfiguration.java
- web.xml, spring-security.xml, and springmvc-servlet.mvc are pulled into this 'WebServiceConfiguration' java class.


With this layout, the modules are setup in this order:
app, entity, dao, service, ws



Does anyone like this structure? Do you hate it? Do you have suggestions on how I should do this? A co-worker has created a very different structure that has these same modules, except that the order is a little different.



He has the modules setup as follows:
entity, dao, service, ws, and app



In this case, the app module is a 'FAT JAR' which has the Spring Boot Application main class. The pom.xml then includes: entity, dao, service, ws.
In his case, the dao does include the entities.
The services do not include the dao, and the ws does not include the services.



What does anyone thing of that layout?



Thanks!










share|improve this question


























    up vote
    0
    down vote

    favorite












    I have a pretty traditional classic Spring web-app that serves up RESTful services as a multi-maven module project.



    There are a lot of great web-sites out there that I have found, and have some have good examples. I can make something work, but that doesn't mean it is a standard approach. So, the reason I am asking here, is for what a standard Spring Boot should be for a RESTful app. Is the layout I am using fairly normal and/or standard, or is it crazy. What is the normal standard layout for a Spring Boot multi-maven module.



    Let me lay this out:



    parent-maven-project
    pom.xml - repos, properties, modules

    entity-module - translates to JAR, all hibernate entities
    myapp-entity-context.xml - beans for mostly the dbconn/session/trx
    pom.xml - points to parent-maven-project has dependencies

    dao-module - translates to jar, all db CRUD and unit tests
    - imports entity-module.jar
    myapp-dao-context.xml
    this xml imports myapp-entity-context.xml
    also has any other bean definitions needed for this module
    pom.xml - points to parent-maven-project has dependencies

    service-module - translates to jar, contains business logic
    - imports dao-module.jar
    myapp-service-context.xml
    this xml imports myapp-dao-context.xml
    also has any other bean definitions needed for this module
    pom.xml - points to parent-maven-project has dependencies

    ws-module - translates to war, contains RESTful endpoints
    - imports service-module.jar
    myapp-ws-context.xml
    this xml imports myapp-service-context.xml
    also has any other bean definitions needed for this module
    pom.xml - points to parent-maven-project has dependencies
    webapp
    WEB-INF
    spring-security.xml
    springmvc-serlet.xml
    web.xml


    Some people may like what I have done by separating out the modules, and seeing how the WAR is pulling the service-module.jar which has the dao-module.jar which has the entity-module.jar, and some may not like it.



    You can see the 'myapp-ws-context.xml' has imported the 'myapp-service-context.xml' which in turn has imported the 'myapp-dao-context.xml' which has in turn imported the fist 'myapp-entity-context.xml'. Some people may like this, and other people may feel like this is an abomination.



    I will say, that in this order, if I compile my modules:

    entity, dao, service, ws
    then everything compiles correctly, and all unit tests run correctly, and the app runs great! This is the system that I have come up with over the years, and it looks very similar to any Spring apps I see now.



    With all this being laid out, I am looking at the 'standard' way of creating a multi-maven module Spring Boot app. So, here is what I know, and here is what I have questions on:



    1) I know all the myapp-xxx-context.xml files should be converted to Java Config classes



    2) I think that the spring-secutity.xml, the web.xml, and springmvc-servlet can all be converted to Java Config classes as well????? For all I know, these three xml files can be put in one Java Config class.



    The overall reason for modules is that I really want to encapsulate what I need for these modules in the pom.xml dependencies, and in the spring application context files.



    Here is a layout that I think I am going to need.



    parent-maven-project
    pom.xml - repos, properties, modules
    - parent is spring boot start project

    app-module - Beginning Spring Boot App, translates to jar
    pom.xml - points to parent-maven-project has dependencies
    src/main/java/com/myapp/AppConfiguration.java

    entity-module - translates to JAR, all hibernate entities
    pom.xml - points to parent-maven-project has dependencies
    src/main/java/com/myapp/EntityConfiguration.java
    - @Import AppConfiguration.java


    dao-module - translates to jar, all db CRUD and unit tests
    - imports entity-module.jar
    pom.xml - points to parent-maven-project has dependencies
    src/main/java/com/myapp/DaoConfiguration.java
    - @Import EntityConfiguration.java

    service-module - translates to jar, contains business logic
    - imports dao-module.jar
    pom.xml - points to parent-maven-project has dependencies
    src/main/java/com/myapp/ServiceConfiguration.java
    - @Import DaoConfiguration.java

    ws-module - translates to war, contains RESTful endpoints
    - imports service-module.jar
    pom.xml - points to parent-maven-project has dependencies
    src/main/java/com/myapp/WebServiceConfiguration.java
    - @Import ServiceConfiguration.java
    - web.xml, spring-security.xml, and springmvc-servlet.mvc are pulled into this 'WebServiceConfiguration' java class.


    With this layout, the modules are setup in this order:
    app, entity, dao, service, ws



    Does anyone like this structure? Do you hate it? Do you have suggestions on how I should do this? A co-worker has created a very different structure that has these same modules, except that the order is a little different.



    He has the modules setup as follows:
    entity, dao, service, ws, and app



    In this case, the app module is a 'FAT JAR' which has the Spring Boot Application main class. The pom.xml then includes: entity, dao, service, ws.
    In his case, the dao does include the entities.
    The services do not include the dao, and the ws does not include the services.



    What does anyone thing of that layout?



    Thanks!










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I have a pretty traditional classic Spring web-app that serves up RESTful services as a multi-maven module project.



      There are a lot of great web-sites out there that I have found, and have some have good examples. I can make something work, but that doesn't mean it is a standard approach. So, the reason I am asking here, is for what a standard Spring Boot should be for a RESTful app. Is the layout I am using fairly normal and/or standard, or is it crazy. What is the normal standard layout for a Spring Boot multi-maven module.



      Let me lay this out:



      parent-maven-project
      pom.xml - repos, properties, modules

      entity-module - translates to JAR, all hibernate entities
      myapp-entity-context.xml - beans for mostly the dbconn/session/trx
      pom.xml - points to parent-maven-project has dependencies

      dao-module - translates to jar, all db CRUD and unit tests
      - imports entity-module.jar
      myapp-dao-context.xml
      this xml imports myapp-entity-context.xml
      also has any other bean definitions needed for this module
      pom.xml - points to parent-maven-project has dependencies

      service-module - translates to jar, contains business logic
      - imports dao-module.jar
      myapp-service-context.xml
      this xml imports myapp-dao-context.xml
      also has any other bean definitions needed for this module
      pom.xml - points to parent-maven-project has dependencies

      ws-module - translates to war, contains RESTful endpoints
      - imports service-module.jar
      myapp-ws-context.xml
      this xml imports myapp-service-context.xml
      also has any other bean definitions needed for this module
      pom.xml - points to parent-maven-project has dependencies
      webapp
      WEB-INF
      spring-security.xml
      springmvc-serlet.xml
      web.xml


      Some people may like what I have done by separating out the modules, and seeing how the WAR is pulling the service-module.jar which has the dao-module.jar which has the entity-module.jar, and some may not like it.



      You can see the 'myapp-ws-context.xml' has imported the 'myapp-service-context.xml' which in turn has imported the 'myapp-dao-context.xml' which has in turn imported the fist 'myapp-entity-context.xml'. Some people may like this, and other people may feel like this is an abomination.



      I will say, that in this order, if I compile my modules:

      entity, dao, service, ws
      then everything compiles correctly, and all unit tests run correctly, and the app runs great! This is the system that I have come up with over the years, and it looks very similar to any Spring apps I see now.



      With all this being laid out, I am looking at the 'standard' way of creating a multi-maven module Spring Boot app. So, here is what I know, and here is what I have questions on:



      1) I know all the myapp-xxx-context.xml files should be converted to Java Config classes



      2) I think that the spring-secutity.xml, the web.xml, and springmvc-servlet can all be converted to Java Config classes as well????? For all I know, these three xml files can be put in one Java Config class.



      The overall reason for modules is that I really want to encapsulate what I need for these modules in the pom.xml dependencies, and in the spring application context files.



      Here is a layout that I think I am going to need.



      parent-maven-project
      pom.xml - repos, properties, modules
      - parent is spring boot start project

      app-module - Beginning Spring Boot App, translates to jar
      pom.xml - points to parent-maven-project has dependencies
      src/main/java/com/myapp/AppConfiguration.java

      entity-module - translates to JAR, all hibernate entities
      pom.xml - points to parent-maven-project has dependencies
      src/main/java/com/myapp/EntityConfiguration.java
      - @Import AppConfiguration.java


      dao-module - translates to jar, all db CRUD and unit tests
      - imports entity-module.jar
      pom.xml - points to parent-maven-project has dependencies
      src/main/java/com/myapp/DaoConfiguration.java
      - @Import EntityConfiguration.java

      service-module - translates to jar, contains business logic
      - imports dao-module.jar
      pom.xml - points to parent-maven-project has dependencies
      src/main/java/com/myapp/ServiceConfiguration.java
      - @Import DaoConfiguration.java

      ws-module - translates to war, contains RESTful endpoints
      - imports service-module.jar
      pom.xml - points to parent-maven-project has dependencies
      src/main/java/com/myapp/WebServiceConfiguration.java
      - @Import ServiceConfiguration.java
      - web.xml, spring-security.xml, and springmvc-servlet.mvc are pulled into this 'WebServiceConfiguration' java class.


      With this layout, the modules are setup in this order:
      app, entity, dao, service, ws



      Does anyone like this structure? Do you hate it? Do you have suggestions on how I should do this? A co-worker has created a very different structure that has these same modules, except that the order is a little different.



      He has the modules setup as follows:
      entity, dao, service, ws, and app



      In this case, the app module is a 'FAT JAR' which has the Spring Boot Application main class. The pom.xml then includes: entity, dao, service, ws.
      In his case, the dao does include the entities.
      The services do not include the dao, and the ws does not include the services.



      What does anyone thing of that layout?



      Thanks!










      share|improve this question













      I have a pretty traditional classic Spring web-app that serves up RESTful services as a multi-maven module project.



      There are a lot of great web-sites out there that I have found, and have some have good examples. I can make something work, but that doesn't mean it is a standard approach. So, the reason I am asking here, is for what a standard Spring Boot should be for a RESTful app. Is the layout I am using fairly normal and/or standard, or is it crazy. What is the normal standard layout for a Spring Boot multi-maven module.



      Let me lay this out:



      parent-maven-project
      pom.xml - repos, properties, modules

      entity-module - translates to JAR, all hibernate entities
      myapp-entity-context.xml - beans for mostly the dbconn/session/trx
      pom.xml - points to parent-maven-project has dependencies

      dao-module - translates to jar, all db CRUD and unit tests
      - imports entity-module.jar
      myapp-dao-context.xml
      this xml imports myapp-entity-context.xml
      also has any other bean definitions needed for this module
      pom.xml - points to parent-maven-project has dependencies

      service-module - translates to jar, contains business logic
      - imports dao-module.jar
      myapp-service-context.xml
      this xml imports myapp-dao-context.xml
      also has any other bean definitions needed for this module
      pom.xml - points to parent-maven-project has dependencies

      ws-module - translates to war, contains RESTful endpoints
      - imports service-module.jar
      myapp-ws-context.xml
      this xml imports myapp-service-context.xml
      also has any other bean definitions needed for this module
      pom.xml - points to parent-maven-project has dependencies
      webapp
      WEB-INF
      spring-security.xml
      springmvc-serlet.xml
      web.xml


      Some people may like what I have done by separating out the modules, and seeing how the WAR is pulling the service-module.jar which has the dao-module.jar which has the entity-module.jar, and some may not like it.



      You can see the 'myapp-ws-context.xml' has imported the 'myapp-service-context.xml' which in turn has imported the 'myapp-dao-context.xml' which has in turn imported the fist 'myapp-entity-context.xml'. Some people may like this, and other people may feel like this is an abomination.



      I will say, that in this order, if I compile my modules:

      entity, dao, service, ws
      then everything compiles correctly, and all unit tests run correctly, and the app runs great! This is the system that I have come up with over the years, and it looks very similar to any Spring apps I see now.



      With all this being laid out, I am looking at the 'standard' way of creating a multi-maven module Spring Boot app. So, here is what I know, and here is what I have questions on:



      1) I know all the myapp-xxx-context.xml files should be converted to Java Config classes



      2) I think that the spring-secutity.xml, the web.xml, and springmvc-servlet can all be converted to Java Config classes as well????? For all I know, these three xml files can be put in one Java Config class.



      The overall reason for modules is that I really want to encapsulate what I need for these modules in the pom.xml dependencies, and in the spring application context files.



      Here is a layout that I think I am going to need.



      parent-maven-project
      pom.xml - repos, properties, modules
      - parent is spring boot start project

      app-module - Beginning Spring Boot App, translates to jar
      pom.xml - points to parent-maven-project has dependencies
      src/main/java/com/myapp/AppConfiguration.java

      entity-module - translates to JAR, all hibernate entities
      pom.xml - points to parent-maven-project has dependencies
      src/main/java/com/myapp/EntityConfiguration.java
      - @Import AppConfiguration.java


      dao-module - translates to jar, all db CRUD and unit tests
      - imports entity-module.jar
      pom.xml - points to parent-maven-project has dependencies
      src/main/java/com/myapp/DaoConfiguration.java
      - @Import EntityConfiguration.java

      service-module - translates to jar, contains business logic
      - imports dao-module.jar
      pom.xml - points to parent-maven-project has dependencies
      src/main/java/com/myapp/ServiceConfiguration.java
      - @Import DaoConfiguration.java

      ws-module - translates to war, contains RESTful endpoints
      - imports service-module.jar
      pom.xml - points to parent-maven-project has dependencies
      src/main/java/com/myapp/WebServiceConfiguration.java
      - @Import ServiceConfiguration.java
      - web.xml, spring-security.xml, and springmvc-servlet.mvc are pulled into this 'WebServiceConfiguration' java class.


      With this layout, the modules are setup in this order:
      app, entity, dao, service, ws



      Does anyone like this structure? Do you hate it? Do you have suggestions on how I should do this? A co-worker has created a very different structure that has these same modules, except that the order is a little different.



      He has the modules setup as follows:
      entity, dao, service, ws, and app



      In this case, the app module is a 'FAT JAR' which has the Spring Boot Application main class. The pom.xml then includes: entity, dao, service, ws.
      In his case, the dao does include the entities.
      The services do not include the dao, and the ws does not include the services.



      What does anyone thing of that layout?



      Thanks!







      java maven spring-boot






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 at 15:59









      tjholmes66

      80212047




      80212047





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53396889%2fconfigure-convert-a-spring-app-to-spring-boot-app%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53396889%2fconfigure-convert-a-spring-app-to-spring-boot-app%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Tonle Sap (See)

          I get strange results when I access the Sqlitedatabase with Unity C# via XAMPP

          Guatemaltekische Davis-Cup-Mannschaft