Debugging Java | Spring RESTful, JPA with Spring Boot | Separation of concerns

This one's a brief update on the previous work on the basic implementation of Spring RESTful with JPA Repositories with separation of business logic and web aspect. I tried to migrate the same project on Spring boot.
The spring boot reference gives an elaborate peak into developing a Spring boot application. Below are a few points which might be helpful from a migration perspective:

  • Boot application to detect entities from classpath: If we require model classes, business logic & JPA Repositories to be detected and injected from a jar in the classpath, scanBasePackages property of @SpringBootApplication will help us wire those with the main class being in a different project hierarchy

  • Config goes away Spring boot removes dependency on having any configuration setup. A web.xml file is also not needed. We can initialize the servlet in the boot main application class. The superpower annotation @SpringBootApplication enables MVC for us and initializes the dispatcher servlets. It additionally scans and wires the beans & components.
  • Specific qualifier infrastructure beans Spring boot configures the application based on the libraries in the classpath. For example, spring-tx-XYZ.jar facilitates configuring of transactionManager, spring-webmvc-XYZ.jar enables mvc in the application etc.
    But spring boot expects specific qualifier beans: for the transaction manager, it will require a bean with the name:
    transactionManager implementing PlatformTransactionManager. If P1.jar doesnt already supply a bean with the name, we must configure the bean with qualifier: transactionManager. We must autowire the EntityManagerFactoryBean as well.

There are definitely many more points to be uncovered while we study & implement the genetics behind Java and related technologies. 

Keep coding, keep exploring! 

Watch this space for more. 

No comments:

Post a Comment