gpt4 book ai didi

gradle - 在gradle项目中使用本地依赖项(通过mvn install安装)

转载 作者:行者123 更新时间:2023-12-03 06:16:14 25 4
gpt4 key购买 nike

任何想法为什么我的Java源代码不能使用build.gradle中声明的依赖项中的类?

项目结构

这是Person.java,其中存在错误World cannot be resolved to a type ..

package org.gradle;

import org.apache.commons.collections.list.GrowthList;

public class Person {
private final String name;

public Person(String name) {
this.name = name;
new GrowthList();

new World(); // World cannot be resolved to a type
}

public String getName() {
return name;
}
}
build.gradle
apply plugin: 'java'
apply plugin: 'eclipse'

sourceCompatibility = 1.5
version = '1.0'
jar {
manifest {
attributes 'Implementation-Title': 'Gradle Quickstart',
'Implementation-Version': version
}
}

repositories {
mavenCentral()
mavenLocal()
}

dependencies {
compile group: 'commons-collections', name: 'commons-collections', version: '3.2'
compile 'org.jbox2d:jbox2d-library:2.3.1-SNAPSHOT'
}

test {
systemProperties 'property': 'value'
}

文件系统 ..
rob@work:~/.m2/repository/org/jbox2d/jbox2d-library/2.3.1-SNAPSHOT$ ls
jbox2d-library-2.3.1-SNAPSHOT.jar jbox2d-library-2.3.1-SNAPSHOT.pom m2e-lastUpdated.properties maven-metadata-local.xml

当我尝试运行 compileJava task ..
[sts] -----------------------------------------------------
[sts] Starting Gradle build for the following tasks:
[sts] compileJava
[sts] -----------------------------------------------------
:compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.5
/home/rob/workspaceMarsM6/Tes/src/main/java/org/gradle/Person.java:12: error: cannot find symbol
new World();
^
symbol: class World
location: class Person
1 error
1 warning
FAILED

最佳答案

通过执行以下1个排序问题..

Gradle -> refresh dependencies

要么
restart eclipse

关于gradle - 在gradle项目中使用本地依赖项(通过mvn install安装),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30464059/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com