【发布时间】:2017-07-17 09:12:26
【问题描述】:
我把我的项目分成了多个模块,core负责数据库访问、业务逻辑等。还有一个模块提供了graphql API。 graphql 模块具有 core 作为其依赖项,但 core 模块中 application.yml 文件的配置似乎没有被加载。
设置
核心 - Application.class
package project.core;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
@ComponentScan
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
application.yml
spring:
application:
name: core # Identify this application
datasource:
url: jdbc:postgresql://localhost:5432/project
username: user
password: something
driver-class-name: org.postgresql.Driver
jpa:
database-platform: org.hibernate.dialect.PostgreSQLDialect
show-sql: true
hibernate:
ddl-auto: create
logging:
level:
org.springframework:
web: TRACE
security: TRACE
GRAPHQL 模块 - POM 层
<dependencies>
<dependency>
<groupId>project</groupId>
<artifactId>core</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
Application.class
@EnableAutoConfiguration
@ComponentScan({"project.core", "project.graphql"})
public class ProjectGraphQL {
public static void main(String[] args) throws Exception {
SpringApplication.run(ProjectGraphQL.class, args);
}
}
将 core 添加到 @ComponentScan 修复了 JPA 的问题,但现在我收到以下错误消息。
***************************应用程序启动失败
说明:
无法确定数据库类型 NONE 的嵌入式数据库驱动程序类
我错过了什么?我相信我可以将配置复制到我的 graphql 配置中,但我宁愿将所有数据库内容排除在该模块之外。
【问题讨论】:
标签: java hibernate jpa spring-boot spring-data