gradle生成失败,任务执行失败';:编译ejava';
我在Java桌面应用程序中使用gradle IDE是NetBeans&我想从Java类中自动生成一些JSON 我实现了3个类(仅仅是pojo)&试图通过gradle导入'com.github.reinert',名称:'jjschema',版本:'1.11' jjschema将打印java对象的JSON等价物 我的gradle版本是4.4和Java C:\Program Files\Java\jdk1.8.0_171(通过检查路径和发出cmd命令gradle-version来确认这两个版本) C:\X\Documents\NetBeansProjects\xMessage>gradle-版本gradle生成失败,任务执行失败';:编译ejava';,java,gradle,build.gradle,Java,Gradle,Build.gradle,我在Java桌面应用程序中使用gradle IDE是NetBeans&我想从Java类中自动生成一些JSON 我实现了3个类(仅仅是pojo)&试图通过gradle导入'com.github.reinert',名称:'jjschema',版本:'1.11' jjschema将打印java对象的JSON等价物 我的gradle版本是4.4和Java C:\Program Files\Java\jdk1.8.0_171(通过检查路径和发出cmd命令gradle-version来确认这两个版本) C:
格拉德尔4.4 构建时间:2017-12-06 09:05:06 UTC 修订:cf7821a6f79f8e2a598df21780e3ff7ce8db2b82 Groovy:2.4.12 Ant:ApacheAnt(TM)版本1.9.9于2017年2月2日编译 JVM:1.8.0_171(Oracle公司25.171-b11) 操作系统:Windows 10.0 amd64 但是gradle没有解析类&没有下载依赖项 这是我的gradle文件:
apply plugin: 'java'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}
repositories {
mavenCentral()
// You may define additional repositories, or even remove "mavenCentral()".
// Read more about repositories here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}
dependencies {
// TODO: Add dependencies here ...
// You can read more about how to add dependency here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
//I also tried compile group: 'com.github.reinert', name: 'jjschema', version: '1.11'
implementation group: 'com.github.reinert', name: 'jjschema', version: '1.11'
}
package x_mqtt_message;
import java.util.ArrayList;
import java.util.List;
public class MobileDevice {
//most likely a phone number tied to the device if available or other id
private String softwareId;
//device's hardwareId, is import if the user changes the phone or swaps SIM cards, we can still identify the hardware for tracking/diagnostics/debugging
private String hardwareId;
//services running on the device
private List<xService> services = new ArrayList<xService>();
public String getSoftwareId() {
return softwareId;
}
public void setSoftwareId(String softwareId) {
this.softwareId = softwareId;
}
public String getHardwareId() {
return hardwareId;
}
public void setHardwareId(String hardwareId) {
this.hardwareId = hardwareId;
}
public List<xService> getServices() {
return services;
}
public void setServices(List<xService> services) {
this.services = services;
}
package x_mqtt_message;
import com.github.reinert.jjschema.Attributes;
@Attributes(title="xSensor", description="An external sensor such as ECG,temp,Accelerometer,Pulse-oximete,Barometric Pressure,etc...")
public class xSensor {
//unique id of the sensor
@Attributes(required=true, description="unique id of the sensor")
private String id;
//type such as ECG,body_temperature,accelerometer,pulse-oximeter,barometric_pressure
@Attributes(required=true, description="type such as ECG,body_temperature,accelerometer,pulse-oximeter,barometric_pressure")
private String type;
@Attributes(minItems=0,uniqueItems=false)
private Object [] data;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Object[] getData() {
return data;
}
public void setData(Object[] data) {
this.data = data;
}
}
package x_mqtt_message;
import com.github.reinert.jjschema.Attributes;
import java.util.HashSet;
@Attributes(title="xService", description="A background process that send & receives data via several protocol")
public class xService {
//service examples: mqtt_service, gps_service, compass_service, bluetooth_service, etc...
@Attributes(required=true, description="mqtt_service, gps_service, compass_service, bluetooth_service, etc...")
private String serviceName;
//is the service 100% up & running yes=true no=false
@Attributes(required=true, description="is the service 100% up & running yes=true no=false")
private Boolean serviceStatus= false;
@Attributes(minItems=0,uniqueItems=true)
private HashSet<xSensor> listOfSensors = new HashSet<xSensor>();
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
}
package x_mqtt_message;
public class x_mqtt_message {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// These packages are NOT being found!!!!
JsonSchemaFactory schemaFactory = new JsonSchemaV4Factory();
schemaFactory.setAutoPutDollarSchema(true);
JsonNode productSchema = schemaFactory.createSchema(MobileDevice.class);
System.out.println(productSchema);
}
}
X类服务:
apply plugin: 'java'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}
repositories {
mavenCentral()
// You may define additional repositories, or even remove "mavenCentral()".
// Read more about repositories here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}
dependencies {
// TODO: Add dependencies here ...
// You can read more about how to add dependency here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
//I also tried compile group: 'com.github.reinert', name: 'jjschema', version: '1.11'
implementation group: 'com.github.reinert', name: 'jjschema', version: '1.11'
}
package x_mqtt_message;
import java.util.ArrayList;
import java.util.List;
public class MobileDevice {
//most likely a phone number tied to the device if available or other id
private String softwareId;
//device's hardwareId, is import if the user changes the phone or swaps SIM cards, we can still identify the hardware for tracking/diagnostics/debugging
private String hardwareId;
//services running on the device
private List<xService> services = new ArrayList<xService>();
public String getSoftwareId() {
return softwareId;
}
public void setSoftwareId(String softwareId) {
this.softwareId = softwareId;
}
public String getHardwareId() {
return hardwareId;
}
public void setHardwareId(String hardwareId) {
this.hardwareId = hardwareId;
}
public List<xService> getServices() {
return services;
}
public void setServices(List<xService> services) {
this.services = services;
}
package x_mqtt_message;
import com.github.reinert.jjschema.Attributes;
@Attributes(title="xSensor", description="An external sensor such as ECG,temp,Accelerometer,Pulse-oximete,Barometric Pressure,etc...")
public class xSensor {
//unique id of the sensor
@Attributes(required=true, description="unique id of the sensor")
private String id;
//type such as ECG,body_temperature,accelerometer,pulse-oximeter,barometric_pressure
@Attributes(required=true, description="type such as ECG,body_temperature,accelerometer,pulse-oximeter,barometric_pressure")
private String type;
@Attributes(minItems=0,uniqueItems=false)
private Object [] data;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Object[] getData() {
return data;
}
public void setData(Object[] data) {
this.data = data;
}
}
package x_mqtt_message;
import com.github.reinert.jjschema.Attributes;
import java.util.HashSet;
@Attributes(title="xService", description="A background process that send & receives data via several protocol")
public class xService {
//service examples: mqtt_service, gps_service, compass_service, bluetooth_service, etc...
@Attributes(required=true, description="mqtt_service, gps_service, compass_service, bluetooth_service, etc...")
private String serviceName;
//is the service 100% up & running yes=true no=false
@Attributes(required=true, description="is the service 100% up & running yes=true no=false")
private Boolean serviceStatus= false;
@Attributes(minItems=0,uniqueItems=true)
private HashSet<xSensor> listOfSensors = new HashSet<xSensor>();
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
}
package x_mqtt_message;
public class x_mqtt_message {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// These packages are NOT being found!!!!
JsonSchemaFactory schemaFactory = new JsonSchemaV4Factory();
schemaFactory.setAutoPutDollarSchema(true);
JsonNode productSchema = schemaFactory.createSchema(MobileDevice.class);
System.out.println(productSchema);
}
}
通过IDE构建时,我得到:
apply plugin: 'java'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}
repositories {
mavenCentral()
// You may define additional repositories, or even remove "mavenCentral()".
// Read more about repositories here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}
dependencies {
// TODO: Add dependencies here ...
// You can read more about how to add dependency here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
//I also tried compile group: 'com.github.reinert', name: 'jjschema', version: '1.11'
implementation group: 'com.github.reinert', name: 'jjschema', version: '1.11'
}
package x_mqtt_message;
import java.util.ArrayList;
import java.util.List;
public class MobileDevice {
//most likely a phone number tied to the device if available or other id
private String softwareId;
//device's hardwareId, is import if the user changes the phone or swaps SIM cards, we can still identify the hardware for tracking/diagnostics/debugging
private String hardwareId;
//services running on the device
private List<xService> services = new ArrayList<xService>();
public String getSoftwareId() {
return softwareId;
}
public void setSoftwareId(String softwareId) {
this.softwareId = softwareId;
}
public String getHardwareId() {
return hardwareId;
}
public void setHardwareId(String hardwareId) {
this.hardwareId = hardwareId;
}
public List<xService> getServices() {
return services;
}
public void setServices(List<xService> services) {
this.services = services;
}
package x_mqtt_message;
import com.github.reinert.jjschema.Attributes;
@Attributes(title="xSensor", description="An external sensor such as ECG,temp,Accelerometer,Pulse-oximete,Barometric Pressure,etc...")
public class xSensor {
//unique id of the sensor
@Attributes(required=true, description="unique id of the sensor")
private String id;
//type such as ECG,body_temperature,accelerometer,pulse-oximeter,barometric_pressure
@Attributes(required=true, description="type such as ECG,body_temperature,accelerometer,pulse-oximeter,barometric_pressure")
private String type;
@Attributes(minItems=0,uniqueItems=false)
private Object [] data;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Object[] getData() {
return data;
}
public void setData(Object[] data) {
this.data = data;
}
}
package x_mqtt_message;
import com.github.reinert.jjschema.Attributes;
import java.util.HashSet;
@Attributes(title="xService", description="A background process that send & receives data via several protocol")
public class xService {
//service examples: mqtt_service, gps_service, compass_service, bluetooth_service, etc...
@Attributes(required=true, description="mqtt_service, gps_service, compass_service, bluetooth_service, etc...")
private String serviceName;
//is the service 100% up & running yes=true no=false
@Attributes(required=true, description="is the service 100% up & running yes=true no=false")
private Boolean serviceStatus= false;
@Attributes(minItems=0,uniqueItems=true)
private HashSet<xSensor> listOfSensors = new HashSet<xSensor>();
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
}
package x_mqtt_message;
public class x_mqtt_message {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// These packages are NOT being found!!!!
JsonSchemaFactory schemaFactory = new JsonSchemaV4Factory();
schemaFactory.setAutoPutDollarSchema(true);
JsonNode productSchema = schemaFactory.createSchema(MobileDevice.class);
System.out.println(productSchema);
}
}
执行:gradle清洁构建
参数:[-c,c:\x\Documents\NetBeansProjects\NgfrMessage\settings.gradle]
:清洁
C:\x\Documents\NetBeansProjects\NgfrMessage\src\main\java\ngfr\u mqtt\u message\ngfr\u mqtt\u message.java:17:错误:找不到符号
JsonSchemaFactory schemaFactory=新的JsonSchemaV4Factory();
^
符号:JsonSchemaFactory类
位置:Ngfr_类mqtt_消息
C:\x\Documents\NetBeansProjects\NgfrMessage\src\main\java\ngfr\u mqtt\u message\ngfr\u mqtt\u message.java:17:错误:找不到符号
JsonSchemaFactory schemaFactory=新的JsonSchemaV4Factory();
^
符号:JsonSchemaV4Factory类
位置:Ngfr_类mqtt_消息
C:\x\Documents\NetBeansProjects\NgfrMessage\src\main\java\ngfr\u mqtt\u message\ngfr\u mqtt\u message.java:19:错误:找不到符号
JsonNode productSchema=schemaFactory.createSchema(MobileDevice.class);
^
符号:类JsonNode
位置:Ngfr_类mqtt_消息
3个错误
:compileJava失败
失败:生成失败,出现异常
- 出了什么问题: 任务“:compileJava”的执行失败 编译失败;有关详细信息,请参阅编译器错误输出
- 尝试: 使用--stacktrace选项运行以获取堆栈跟踪。使用--info或--debug选项运行以获得更多日志输出。使用--scan运行以获得完整的洞察力
apply plugin: 'java'
sourceCompatibility = '1.8'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
// NetBeans will automatically add "run" and "debug" tasks relying on the
// "mainClass" property. You may however define the property prior executing
// tasks by passing a "-PmainClass=<QUALIFIED_CLASS_NAME>" argument.
//
// Note however, that you may define your own "run" and "debug" task if you
// prefer. In this case NetBeans will not add these tasks but you may rely on
// your own implementation.
if (!hasProperty('mainClass')) {
ext.mainClass = ''
}
repositories {
mavenCentral()
// You may define additional repositories, or even remove "mavenCentral()".
// Read more about repositories here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:repositories
}
dependencies {
// TODO: Add dependencies here ...
// You can read more about how to add dependency here:
// http://www.gradle.org/docs/current/userguide/dependency_management.html#sec:how_to_declare_your_dependencies
//I also tried compile group: 'com.github.reinert', name: 'jjschema', version: '1.11'
implementation group: 'com.github.reinert', name: 'jjschema', version: '1.11'
}
package x_mqtt_message;
import java.util.ArrayList;
import java.util.List;
public class MobileDevice {
//most likely a phone number tied to the device if available or other id
private String softwareId;
//device's hardwareId, is import if the user changes the phone or swaps SIM cards, we can still identify the hardware for tracking/diagnostics/debugging
private String hardwareId;
//services running on the device
private List<xService> services = new ArrayList<xService>();
public String getSoftwareId() {
return softwareId;
}
public void setSoftwareId(String softwareId) {
this.softwareId = softwareId;
}
public String getHardwareId() {
return hardwareId;
}
public void setHardwareId(String hardwareId) {
this.hardwareId = hardwareId;
}
public List<xService> getServices() {
return services;
}
public void setServices(List<xService> services) {
this.services = services;
}
package x_mqtt_message;
import com.github.reinert.jjschema.Attributes;
@Attributes(title="xSensor", description="An external sensor such as ECG,temp,Accelerometer,Pulse-oximete,Barometric Pressure,etc...")
public class xSensor {
//unique id of the sensor
@Attributes(required=true, description="unique id of the sensor")
private String id;
//type such as ECG,body_temperature,accelerometer,pulse-oximeter,barometric_pressure
@Attributes(required=true, description="type such as ECG,body_temperature,accelerometer,pulse-oximeter,barometric_pressure")
private String type;
@Attributes(minItems=0,uniqueItems=false)
private Object [] data;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Object[] getData() {
return data;
}
public void setData(Object[] data) {
this.data = data;
}
}
package x_mqtt_message;
import com.github.reinert.jjschema.Attributes;
import java.util.HashSet;
@Attributes(title="xService", description="A background process that send & receives data via several protocol")
public class xService {
//service examples: mqtt_service, gps_service, compass_service, bluetooth_service, etc...
@Attributes(required=true, description="mqtt_service, gps_service, compass_service, bluetooth_service, etc...")
private String serviceName;
//is the service 100% up & running yes=true no=false
@Attributes(required=true, description="is the service 100% up & running yes=true no=false")
private Boolean serviceStatus= false;
@Attributes(minItems=0,uniqueItems=true)
private HashSet<xSensor> listOfSensors = new HashSet<xSensor>();
public String getServiceName() {
return serviceName;
}
public void setServiceName(String serviceName) {
this.serviceName = serviceName;
}
}
package x_mqtt_message;
public class x_mqtt_message {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// These packages are NOT being found!!!!
JsonSchemaFactory schemaFactory = new JsonSchemaV4Factory();
schemaFactory.setAutoPutDollarSchema(true);
JsonNode productSchema = schemaFactory.createSchema(MobileDevice.class);
System.out.println(productSchema);
}
}
17:33:42.834[DEBUG][org.gradle.internal.progress.DefaultBuildOperationExecutor]正在完成生成操作“Task:compileJava”
17:33:42.834[null][org.gradle.internal.progress.DefaultBuildOperationExecutor]
17:33:42.834[调试][org.gradle.internal.progress.DefaultBuildOperationExecutor]生成操作“任务:compileJava”已完成
17:33:42.835[INFO][org.gradle.execution.taskgraph.DefaultTaskPlanExecutor]:已完成compileJava(线程[Task worker for':',5,main])。花了0.267秒。
17:33:42.835[DEBUG][org.gradle.internal.work.DefaultWorkerLeaseService]工作线程租约根目录。1.2已完成(1个工作线程正在使用)
17:33:42.835[DEBUG][org.gradle.internal.resources.AbstractTrackedResourceLock]的任务工作程序“:”:释放了root.1.2上的锁
17:33:42.835[DEBUG][org.gradle.internal.resources.AbstractTrackedResourceLock]任务工作程序,用于“:”:解除了对:
17:33:42.836[DEBUG][org.gradle.execution.taskgraph.DefaultTaskPlanExecutor]任务工作线程[Thread[Task worker for':'Thread 6,5,main]]完成,忙:0.0秒,空闲:0.277秒
17:33:42.836[DEBUG][org.gradle.execution.taskgraph.DefaultTaskPlanExecutor]任务工作线程[Thread[Task worker for':'Thread 7,5,main]]完成,忙:0.0秒,空闲:0.278秒
17:33:42.837[DEBUG][org.gradle.execution.taskgraph.DefaultTaskPlanExecutor]任务工作线程[Thread[Daemon worker Thread 10,5,main]]完成,忙:0.0秒,空闲:0.278秒
17:33:42.836[DEBUG][org.gradle.execution.taskgraph.DefaultTaskPlanExecutor]任务工作线程[Thread[Task worker for':'Thread 5,5,main]]完成,忙:0.0秒,空闲:0.277秒
17:33:42.837[DEBUG][org.gradle.execution.taskgraph.DefaultTaskPlanExecutor]任务工作线程[Thread[Task worker for':',5,main]]完成,忙:0.267秒,空闲:0.012秒
17:33:42.837[DEBUG][org.gradle.execution.taskgraph.DefaultTaskPlanExecutor]任务工作线程[Thread[Task worker for':'Thread 2,5,main]]完成,忙:0.0秒,空闲:0.278秒
17:33:42.836[DEBUG][org.gradle.execution.taskgraph.DefaultTaskPlanExecutor]任务工作线程[Thread[Task worker for':'Thread 3,5,main]]完成,忙:0.0秒,空闲:0.278秒
17:33:42.836[DEBUG][org.gradle.execution.taskgraph.DefaultTaskPlanExecutor]任务工作线程[Thread[Task worker for':'Thread 4,5,main]]完成,忙:0.0秒,空闲:0.278秒
17:33:42.839[调试][org.gradle.internal.progress.DefaultBuildOperationExecutor]正在完成生成操作“运行任务”
17:33:42.844[错误][org.gradle.internal.buildevents.BuildExceptionReporter]
17:33:42.844[错误][org.gradle.internal.buildevents.BuildExceptionReporter]失败:生成失败,出现异常。
17:33:42.845[错误][org.gradle.internal.buildevents.BuildExceptionReporter]
17:33:42.845[错误][org.gradle.internal.buildevents.BuildExceptionReporter]*出了什么问题:
17:33:42.845[错误][org.gradle.internal.buildevents.BuildExceptionReporter]任务“:compileJava”的执行失败。
17:33:42.845[错误][org.gradle.internal.buildevents.BuildExceptionReporter]>编译失败;有关详细信息,请参阅编译器错误输出。
17:33:42.845[错误][org.gradle.internal.buildevents.BuildExceptionReporter]
17:33:42.845[错误][org.gradle.internal.buildevents.BuildExceptionReporter]*尝试:
17:33:42.845[错误][org.gradle.internal.buildevents.BuildExceptionReporter]使用--stacktrace选项运行以获取堆栈跟踪。使用--scan t运行