我有两个弹簧启动应用程序,一个作为依赖项添加到另一个。依赖子项目能够自行运行。创建了能够访问的分类器。
@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);
}
}
此应用程序与其自己的数据源,控制器和放大器完美配合。建议
添加了子项目:
<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>
父项目Spring启动应用程序:
@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
从父项扫描子项目,但数据源初始化失败。
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)
看起来没有调用子项目中的@SpringBootApplication来初始化yml文件。
任何见解都会有所帮助