我在一个Java桌面应用程序中使用gradle。
IDE是NetBeans&我想从我的Java类生成一些自动化的JSON。
我实现了3个类(仅POJOs)&试图通过Gradle导入'com.github.reinert',名称:'jjschema',版本:'1.11'。
jjschema将打印java对象的JSON等价物。
然而,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'
}
以下是我的POJO,按移动设备顺序排列:
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);
}
}
:Clean C:\x\documents\netbeansprojects\ngfrmessage\src\main\java\ngfr_mqtt_message\ngfr_mqtt_message.java:17:错误:找不到符号JsonSchemaFactory schemaFactory=new jsonschemaav4Factory();^symbol:类JsonSchemaFactory位置:类Ngfr_mqtt_message C:\x\documents\netbeansprojects\ngfrmessage\src\main\java\Ngfr_mqtt_message\Ngfr_mqtt_message\Ngfr_mqtt_message.java:17:错误:找不到符号JsonSchemaFactory schemaFactory=new jsonschemaav4Factory();^symbol:类JSONSchemaV4工厂位置:类Ngfr_mqtt_message C:\X\documents\netbeansProjects\ngFRMessage\src\main\java\Ngfr_mqtt_message\Ngfr_mqtt_message\Ngfr_mqtt_message.java:19:错误:找不到符号JsonNode productSchema=schemafactory.createSchema(mobiledevice.class);^symbol:类JsonNode位置:类Ngfr_mqtt_message 3错误:compilejava失败
失败:生成失败,出现异常。
>
错误:任务':compilejava'执行失败。
编译失败;有关详细信息,请参阅编译器错误输出。
但是在x_mqtt_message
中没有导入JSONSchemafactory
。因此编译器找不到这些类。
我正试图在Intellij Idea中导入Gradle项目,并得到一个错误。采取了以下步骤: “导入项目”->打开build.gradle文件 选中“使用默认分级包装(推荐)”。 按“OK”并得到对话框窗口,其中包含消息“编译失败,退出代码为2;有关详细信息,请参阅编译器错误输出。有关详细信息,请参阅IDE日志(帮助显示日志)” 打开日志文件并看到以下堆栈跟踪:
错误: 项目结构: build.gradle(actionbarsherlock) 建筑格拉德尔(vertretungsplan) 设置。格拉德尔 如何修复此错误?
我有一个多项目gradle构建,Spring Boot按照默认gradle约定进行结构化。 我目前的项目是(A)将gradle从5. x升级到7.3. x,(B)使用带有Spring Boot的嵌入式Tomcat。 这是一个已经存在很多年的项目,是Spring Boot,但是传统上一直作为一个战争文件部署在Tomcat中。 我已经按照gradle迁移指南将gradle升级到7.3.3,并正确构建了
谁有办法修好它?只是随机的...此处为完整stacktrace:
今天在Android Studio中,我重建了这个项目,我得到了这个错误。该项目在重建前很好。我没有更改代码中的任何内容。 这是一种错误吗?谢谢
我正在尝试在eclipse中设置我的第一个gradle项目,但我在构建gradle时遇到了问题。我已经从spring.io复制了build.gradle,但它仍然无法正常构建。我得到任务执行失败:编译Java。我的build.gradle文件如下所示