我使用Java构建了两个项目
myproject-db使用spring starter jpa作为依赖项,我能够构建和安装它。
myproject-api -是一个spring引导项目,它使用myproject-db作为依赖项。当我运行myproject-api项目时,会出现错误。
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable driver class我在myproject-db中定义了我的dataSource url application.properties文件,如下所示
spring.datasource.url=jdbc:mysql://localhost:3306/somedb?useSSL=false
spring.datasource.username=root
spring.datasource.password=somepassmyproject的application.properties文件是空的。
问题是为什么我会犯这个错误。
发布于 2018-10-08 10:32:29
您应该配置一个带有依赖模块的Spring交付应用程序
举个例子
myproject-parent
|
myproject-api
myproject-ui如果您的交付项目(主war/jar)是myproject-api,那么application.properties和@Configuration必须在myproject-api和@SpringBootApplication范围内配置。
不能有两个@SpringBootApplication作用域
https://stackoverflow.com/questions/52696586
复制相似问题