没有编写用于连接到Hive的Java类,并做了gradle任务来构建具有所有依赖项的JAR
task Hive(type: Jar) {
manifest {
attributes 'Implementation-Title': 'Gradle Jar File Example',
'Implementation-Version': version,
'Main-Class': 'ru.prometheus.nodeexporters.Hive'
}
baseName = project.name + '-Node_Exporter'
// from('src/main/java') {
// include 'resources/*'
// }
from {
configurations.runtime.collect {
it.isDirectory() ? it : zipTree(it)
}
}
with jar
}
执行任务
12:55:46: Executing task 'Hive'...
> Task :Hive:compileJava
Note: C:\Servers\Repository\PrometheusNodeExporters\Hive\src\main\java\ru\prometheus\nodeexporters\Hive.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: C:\Servers\Repository\PrometheusNodeExporters\Hive\src\main\java\ru\prometheus\nodeexporters\Hive.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
> Task :Hive:processResources
> Task :Hive:classes
> Task :Hive:Hive
Deprecated Gradle features were used in this build, making it incompatible with Gradle 5.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/4.10.2/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 26s
3 actionable tasks: 3 executed
12:56:13: Task execution finished 'Hive'.
之后检查了JAR
确实存在主类,但是否尝试执行返回的错误
c:\Servers\Repository\PrometheusNodeExporters\Hive\build\libs>java -jar Hive-Nod
e_Exporter-1.0-SNAPSHOT.jar
Error: Could not find or load main class ru.prometheus.nodeexporters.Hive
如何解决这个“简单”的问题?
在GitHub上的项目