我已经使用Maven项目创建了依赖罐,但是现在我必须将此Maven依赖添加到我的gradle项目中。
.m2
目录中有依赖关系
正在从intellij获取以下错误。
Execution failed for task ':compileJava'.
> Could not resolve all files for configuration ':compileClasspath'.
> Cannot convert URL 'com.example.auth.security:common:0.0.1-SNAPSHOT.jar' to a file.
请找到我的build.gradle
档案
plugins {
id 'org.springframework.boot' version '2.1.16.RELEASE'
id 'io.spring.dependency-management' version '1.0.9.RELEASE'
id 'java'
id 'war'
}
group = 'com.example.auth'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '1.8'
repositories {
mavenCentral()
}
dependencies {
implementation files('com.example.auth.security:common:0.0.1-SNAPSHOT.jar') --> getting error on this line.
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'org.springframework.security:spring-security-test'
compileOnly 'org.projectlombok:lombok'
implementation('io.jsonwebtoken:jjwt:0.9.1')
}
更新1
A problem occurred evaluating root project 'auth-center'.
> Supplied String module notation '0.0.1-SNAPSHOT' is invalid. Example notations: 'org.gradle:gradle-core:2.2', 'org.mockito:mockito-core:1.9.5:javadoc'.
您将需要添加一个本地Maven存储库,如下所示
repositories {
maven { url new File(pathToYourM2Directory).toURI().toURL() }
}
此外,依赖项的声明不正确。它应该是
dependencies {
implementation group: 'com.example.auth.security', name: 'common', version '0.0.1-SNAPSHOT'
}
您也可以修复files
依赖性。但是,使用本地Maven回购协议更具可持续性,因为通过这种方式解析工件,如果在本地或远程解析工件,则对构建过程而言是透明的。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句