将自定义Maven依赖项添加到Gradle项目

Karthikeyan:

我已经使用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'.
dpr:

您将需要添加一个本地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] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

将自定义 *.jar 文件添加到 build.gradle 项目依赖项中并设置类路径

将自定义 jar(带依赖项)依赖项添加到 pom.xml

Azure App见解-将自定义属性添加到依赖项调用

将自定义命令添加到 gradle 脚本

将自定义字体添加到cordova项目

如何将自定义Maven存储库添加到Gradle

将项目的依赖添加到我的自定义gradle插件中

Java swing:将自定义图形按钮添加到JTree项

无法将自定义 PowerPoint 加载项添加到功能区

如何将自定义工具提示项添加到Apexcharts?

将自定义功能添加到任务窗格加载项

如何将自定义polyfill添加到angular-cli项目?

将自定义项目模板添加到GitLab

使用CocoaPods时如何将自定义项目配置添加到Xcode?

将自定义HTML帮助器添加到MVC项目

如何使用菜单布局将自定义项目添加到NavigationView?

Angular将自定义.css文件添加到Angular-CLI项目

将自定义按钮组添加到Outlook中的Home功能区-VSTO项目

如何将自定义项目符号添加到tinyMCE?

将自定义项目模板添加到Mac的Visual Studio预览版

将自定义工作流程添加到“创建项目”屏幕

Wix无法将自定义操作添加到项目

将自定义信息添加到Office365中的日历项目

将自定义jar添加到Maven本地存储库

将自定义函数添加到对象原型

R:将自定义图例添加到ggplot

将自定义动画添加到popToRootViewController

将自定义元素添加到ngRepeat列表

将自定义样式的按钮添加到CKEditor