I am developing a multi-module project in Spring Boot, where the project structure is as follows:
com.app.parent <- parent pom with version numbers and common dependencies (POM) com.app.core <- repository and service layer, models, DTOs (JAR) com.app.rest <- rest API (WAR) com.app.soap <- soap API (WAR)
The pom.xml file for the parent project:
<artifactId>app-parent</artifactId> <packaging>pom</packaging> <name>app-parent</name> <parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.5.3.RELEASE</version> <relativePath/> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
The pom.xml file for the core project:
<artifactId>app-core</artifactId> <packaging>jar</packaging> <name>app-core</name> <parent> <groupId>com.app</groupId> <artifactId>app-parent</artifactId> <version>0.0.1-SNAPSHOT</version> <relativePath>../app-parent/pom.xml</relativePath> </parent> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> </dependency> </dependencies>
pom.xml for a leisure project:
<artifactId>app-rest</artifactId> <packaging>war</packaging> <name>app-rest</name> <parent> <groupId>com.app</groupId> <artifactId>app-parent</artifactId> <version>0.0.1-SNAPSHOT</version> <relativePath>../app-parent/pom.xml</relativePath> </parent> <dependencies> <dependency> <groupId>com.app</groupId> <artifactId>app-core</artifactId> <version>0.0.1-SNAPSHOT</version> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> </dependencies>
The entry point for the app-core project is:
@SpringBootApplication public class CoreApplication { public static void main(String[] args) { SpringApplication.run(CoreApplication.class, args); } }
The entry point for the app-rest project looks exactly the same.
I created an application.properties file inside core/src/main/resources/ that contains the database configuration, etc., and I can just compile / test the app-core project. However, when I try to run or test the app-rest project, I get errors related to the absence of the application.properties file
Cannot determine the built-in database class class for the database type NONE. If you want an embedded database, put it in the classpath.
How to get a child project to load the parent application.properties file? Should I create a symlink to the parent file, or can I explicitly load the parent property file via @PropertySource ? What are others doing in this scenario?