【发布时间】:2022-12-13 21:59:09
【问题描述】:
我尝试使用库中的 conf 文件,但 application.yml 看不到 lib 的类路径
这是我的 gradle.build
<1234565 class="剧透">plugins {
id 'java'
id 'org.springframework.boot' version '2.7.6'
id 'io.spring.dependency-management' version '1.1.0'
}
group = 'common'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '8'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
flatDir {
dirs 'libs'
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-jdbc'
implementation 'org.mockito:mockito-core:4.9.0'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation group: 'ma.glasnost.orika', name: 'orika-core', version: '1.5.4'
implementation 'common:0.3.2'
implementation group: 'org.springdoc', name: 'springdoc-openapi-ui', version: '1.6.13'
implementation group: 'com.oracle.database.jdbc', name: 'ojdbc8', version: '21.7.0.0'
implementation 'org.postgresql:postgresql'
implementation 'org.jetbrains:annotations:23.0.0'
implementation 'org.springframework.boot:spring-boot-starter-cache:2.7.6'
implementation 'org.springframework.boot:spring-boot-starter-data-redis:2.7.6'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}
tasks.named('test') {
useJUnitPlatform()
}
有人可以解释我做错了什么吗?
【问题讨论】:
-
看起来您正在配置 Gradle 以从
libs目录加载工件,这与将这些东西放在类路径中不同。如果没有更多信息,很难确定,但我怀疑你想要那些 sql 文件在你的运行时类路径中,如果是这样,将它们放在src/main/resources/中并删除你的flatDir东西可能是正确的做法。