- Create project using Spring Initializer and Select option "Maven POM" in type. Which only includes POM file not src and other structure. Open pom.xml and set packaging type : pom instead of jar. Remove web dependency and maven plugin and put in web module.
- Add new module ; Right click on project -> New -> Module Select maven for create project not select arch type select jvm version. Click next add group id and finish. Change packaging type to jar.
- For loading module dependency define that module in dependencies section.
Like,
com.dhwanil persistence 0.0.1-SNAPSHOT - Add dependency of starter jpa and h2 database.
- Add database configuration in application.properties file.
- Create entity in domain module.
- Create repository and service files in persistence module.
- Create controller file in web module.
- Create java file for MultiModuleDemo which contain main method or starting execution point.
- Errors :
- Service class not work @ComponentScan("com.dhwanil.repositories")
- Repository class not work. @EnableJpaRepositories(basePackages = {"com.dhwanil.repositories"})
- Entity class not work. @EntityScan("com.dhwanil.domain")
- For permanently store persistence data we need to update url in application.config spring.datasource.url=jdbc:h2:file:/<db_file_without_extension>;