我试图用gradlew来运行gradle。我的文件夹结构如下所示:java 1.8 - gradle找不到主类
src
└── main
└── java
└── hello
└── Greeting.java
这是我的build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:1.5.8.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'application'
apply plugin: 'eclipse'
apply plugin: 'idea'
apply plugin: 'org.springframework.boot'
mainClassName = 'hello.Greeting'
sourceSets.main.java.srcDirs = ['src']
jar {
baseName = 'gs-rest-service'
version = '0.1.0'
}
repositories {
mavenCentral()
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencies {
compile("org.springframework.boot:spring-boot-starter-web")
testCompile('org.springframework.boot:spring-boot-starter-test')
}
我可以./gradlew运行成功打造,但./gradlew运行退出时:
Task :run
Error: Could not find or load main class hello.Greeting
Greeting.java只是一个带有主要方法的简单类:
package main.java.hello;
public class Greeting {
public static void main(String[] args) {
System.out.println("greet");
}
}
您能向我们展示您的主类(Greeting.java)源代码吗? – adarshr
我怀疑你的java构建路径。杰尔没有认出你的主班。 ? –
@adarshr我更新了我的问题以显示主要课程。 – wedran