I have two spring boot applications one is getting added as a dependency to the other. Dependent child project was able to run on it own. Created the classifier to be able to access.
@SpringBootApplication(scanBasePackages = "com.project.subproject")
public class Application {
public static void main(String args[]) {
new SpringApplicationBuilder(Application.class)
.properties("spring.config.name=application-subproject-default").run(args);
}
}
This application works perfectly fine with its own datasource, controllers & advice
Child project is added :
<dependency>
<groupId>com.project.subproject</groupId>
<artifactId>subproject</artifactId>
<version>0.0.1-SNAPSHOT</version>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-undertow</artifactId>
</exclusion>
</exclusions>
Parent project Spring boot application :
@SpringBootApplication(scanBasePackages = "com.project")
public class MainApplication {
public static void main(String args[]) {
new SpringApplicationBuilder(MainApplication.class).properties("spring.config.name=application-parent-default").run(args);
}
}
application-parent-default.yml
spring:
application:
name: parent
Subproject is getting scanned from the parent, but the datasource initialization is failing.
Unsatisfied dependency expressed through field 'jdbcTemplate';
nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'org.springframework.boot.autoconfigure.jdbc.JdbcTemplateAutoConfiguration': Unsatisfied dependency expressed through constructor parameter 0;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'dataSource' defined in class path resource [org/springframework/boot/autoconfigure/jdbc/DataSourceConfiguration$Hikari.class]: Bean instantiation via factory method failed;
nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.zaxxer.hikari.HikariDataSource]: Factory method 'dataSource' threw exception;
nested exception is org.springframework.boot.autoconfigure.jdbc.DataSourceProperties$DataSourceBeanCreationException:
Cannot determine embedded database driver class for database type NONE. If you want an embedded database please put a supported one on the classpath.
If you have database settings to be loaded from a particular profile you may need to active it (no profiles are currently active)
Looks like the @SpringBootApplication in the child project is not getting invoked to initialize the yml file.
Any insights will be helpful