[英]Java : spring-boot-starter-data-jpa dependency in a dependent project
I have build two projects using Java 我已经用Java建立了两个项目
myproject-db uses spring-boot-starter-data-jpa as a dependency and I am able to build and install it all fine. myproject-db使用spring-boot-starter-data-jpa作为依赖项,我能够很好地构建和安装它。
myproject-api - is a spring boot project and it uses myproject-db as a dependency. myproject-api-是一个春季启动项目,它使用myproject-db作为依赖项。 When I run my myproject-api project it gives me error
当我运行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
I have defined my dataSource url application.properties file in myproject-db like below 我已经在myproject-db中定义了dataSource url application.properties文件,如下所示
spring.datasource.url=jdbc:mysql://localhost:3306/somedb?useSSL=false
spring.datasource.username=root
spring.datasource.password=somepass
application.properties file of myproject-api is empty. myproject-api的application.properties文件为空。
Question is why am I getting this error. 问题是为什么我会收到此错误。
You should have one delivery application configured with Spring Boot with dependent modules 您应该使用Spring Boot配置一个带有依赖模块的交付应用程序
You can have for example 你可以有例如
myproject-parent
|
myproject-api
myproject-ui
If your delivery project (main war/jar) is myproject-api then application.properties and @Configuration
must be configured in myproject-api
and in @SpringBootApplication
scope 如果您的交付项目(主要战争/罐子)是myproject-api,则必须在
myproject-api
和@SpringBootApplication
范围内配置application.properties和@Configuration
You cannot have two @SpringBootApplication
scopes 您不能有两个
@SpringBootApplication
范围
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.