gpt4 book ai didi

java - Birt报表-IReportEngineFactory为空

转载 作者:行者123 更新时间:2023-12-03 05:42:09 25 4
gpt4 key购买 nike

我在Eclipse上使用BIRT没问题,但是我的新公司使用IntelliJ IDEA。

在Gradle中使用项目

compile files('src/main/resources/lib/flute-1.3.jar') 
compile(group: 'org.eclipse.birt.runtime', name: 'org.eclipse.birt.runtime', version: '4.4.2') { exclude(group: 'org.milyn', module: 'flute') }

通过main方法运行本地时,我没有问题。但是通过编译项目后
shadowJar { 
classifier = null
version = version
manifest {
attributes 'Main-Class': 'io.vertx.core.Starter'
attributes 'Main-Verticle': 'other.app.App'
}
mergeServiceFiles {
include 'META-INF/services/io.vertx.core.spi.VerticleFactory'
}
}

我没有
IReportEngineFactory factory = (IReportEngineFactory) Platform .createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);

试图解决这个问题一个星期,我仍然找不到解决方案。有人有什么建议吗?阅读的烦恼。

我的代码就可以了:
 @Override
public void generateUserInformationPdf(JsonObject payload) {

try {

LOGGER.info("Starting render User Information");

/* begin get parameters */

CommonRequest request = gson.fromJson(payload, CommonRequest.class);

UserPdfPrint userInformation = gson.fromJson(request.getData(), UserPdfPrint.class);

String p_username = userInformation.getUsername();
String p_customername = userInformation.getCustomerName();
String p_dob = userInformation.getDob();
String p_license = userInformation.getLicense();
String p_licensedate = userInformation.getLicenseDate();
String p_licenseplace = userInformation.getLicensePlace();
String p_sex = userInformation.getSex();
String p_customerphone = userInformation.getCustomerPhone();
String p_email = userInformation.getEmail();
int p_licensetype = userInformation.getLicenseType();


/* end get parameters section */

/* load report design */
String reportName = config.getReportUserInformation();
IReportEngine engine = null;
IReportRunnable design = null;

URL url = null;
url = new URL(config.getReportFontConfig());

engineConfig = new EngineConfig();
engineConfig.setEngineHome("ReportEngine");
engineConfig.setLogConfig(null, Level.FINE);
engineConfig.setFontConfig(url);

Platform.startup(engineConfig);

IReportEngineFactory factory = (IReportEngineFactory) Platform
.createFactoryObject(IReportEngineFactory.EXTENSION_REPORT_ENGINE_FACTORY);

engine = factory.createReportEngine(engineConfig);

design = engine
.openReportDesign(config.getReportTemplatePath()
+ "/" + reportName); // report

/* end load report design */

/* begin render report */
IRunAndRenderTask task = null;
PDFRenderOption renderContext = null;
HashMap contextMap = null;

task = engine.createRunAndRenderTask(design);
renderContext = new PDFRenderOption();
contextMap = new HashMap();
contextMap.put(EngineConstants.APPCONTEXT_HTML_RENDER_CONTEXT,
renderContext);
contextMap.put("OdaJDBCDriverPassInConnection", config.getDbConnection());
task.setAppContext(contextMap);

task.setParameterValue("p_username", p_username);
task.setParameterValue("p_customername", p_customername);
task.setParameterValue("p_dob", p_dob);
task.setParameterValue("p_license", p_license);
task.setParameterValue("p_licensedate", p_licensedate);
task.setParameterValue("p_licenseplace", p_licenseplace);
task.setParameterValue("p_sex", p_sex);
task.setParameterValue("p_licensetype", String.valueOf(p_licensetype));
task.setParameterValue("p_email", p_email);
task.setParameterValue("p_customerphone", p_customerphone);
task.validateParameters();

String random = Generator.generateRandomNumber();

String today = DateTimes.getCurrentDate().toString();

String parsedToDate = DateTimes.parseDate(today, "EE MMM dd HH:mm:ss z yyyy").toString();

String toDateString = DateTimes.parseDate(parsedToDate, "dd-MM-yyyy-hh-mm-ss").toString();

String reportNameInFolder = "UserInformation" + toDateString
+ random;

String outPutFile = config.getReportOutputPath() + reportNameInFolder + ".pdf";

PDFRenderOption options = null;
options = new PDFRenderOption();
options.setOutputFormat("pdf");
options.setOutputFileName(outPutFile);

task.setRenderOption(options);
task.run();

System.out.println("All went well. Closing program!");

/* end render report */

engine.destroy();
task.close();
options.closeOutputStreamOnExit(true);

mqAdapter.pushToMQ(Transformers.toVertxJsonObject(new EnhancedSuccessResponse()
.setHeader(request.getHeader())
.setCodes(CodeResponse.SuccessCode.PRINT_PDF_REGISTER_SUCCESS.getCode())
.setData(gson.toJsonTree(new PdfReportResponse().setPdfLink(config.getReportOutputLink() + reportNameInFolder + ".pdf")))).encode(), QueueKeys.OtherQueue.ADMIN_GENERATE_USER_INFORMATION_PDF.getValue());

} catch (MalformedURLException e) {
LOGGER.error("Failed to get Font Config URL. {}", e.toString());
} catch (BirtException e1) {
LOGGER.error("Failed to start config. {}", e1.toString());
// e1.printStackTrace();
} catch (
Exception e) {
LOGGER.error("Failed to get design template. {}", e.toString());
System.err
.println("An error occured while running the report!");
LOGGER.error("An error occured while running the report! {}", e.toString());
// e.printStackTrace();
}
}

最佳答案

我也遇到过同样的问题。更新构建gradle并添加

"flute-1.3.jar" & "org.eclipse.orbit.mongodb-2.10.1.v20130422-1135.jar"



lib 文件夹中。
//Start of birt
compile(group: 'org.eclipse.birt.runtime', name: 'org.eclipse.birt.runtime', version: '4.4.2') {
exclude(group: 'org.milyn', module: 'flute')
exclude(group: 'org.eclipse.birt.runtime', module: 'org.eclipse.orbit.mongodb')
}
//End of birt

关于java - Birt报表-IReportEngineFactory为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52214609/

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