Does it cause any problems if I have @Builder annotation in my object model? #300
Unanswered
hyunjoolee
asked this question in
Q&A
Replies: 1 comment
-
@hyunjoolee Hi! you can try https://github.com/vaa25/poiji2 . it supports immutability including lombok @builder and @value |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I am using poiji like below. Could you please answer my question.
@Getter
@excelsheet("Model")
public class model {
}
@builder
@Getter
@excelsheet("model2")
public class model2 {
}
Below are sample code to use Poiji.
PoijiOptions.PoijiOptionsBuilder optionsBuilder = PoijiOptions.PoijiOptionsBuilder.settings();
for(int sheetIndex = 0; sheetIndex < TOTAL_SHEET_COUNT; sheetIndex++) {
optionsBuilder.sheetIndex(sheetIndex).skip(1);
if(sheetIndex == 1)
List < model > model_list = Poiji.fromExcel(file, model.class, optionsBuilder.build());
esle if(sheetIndex == 2)
List < model2 > model2_list = Poiji.fromExcel(file, model2.class, optionsBuilder.build());
}
When I run the above code, I get the error message below: Only Model2 has an error. I think the only difference between Model and Model2 is the @builder annotation.
Should I avoid using the @builder annotation on object model when using the Poiji library?
My development environment is based on windows 10, springboot 3.1.2, jdk17, poiji 4.1.2.
java.lang.NoSuchMethodException: com.example.application.MyModel2.()
at java.base/java.lang.Class.getConstructor0(Class.java:3585)
at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2754)
at com.poiji.util.ReflectUtil.newInstanceOf(ReflectUtil.java:22)
at com.poiji.bind.mapping.PoijiHandler.startRow(PoijiHandler.java:191)
at org.apache.poi.xssf.eventusermodel.XSSFSheetXMLHandler.startElement(XSSFSheetXMLHandler.java:260)
at com.poiji.bind.mapping.XSSFSheetXMLPoijiHandler.startElement(XSSFSheetXMLPoijiHandler.java:67)
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:518)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(XMLNSDocumentScannerImpl.java:374)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2726)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:605)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:112)
at java.xml/com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:542)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:889)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:825)
at java.xml/com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
at java.xml/com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1224)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:637)
at com.poiji.bind.mapping.XSSFUnmarshaller.processSheet(XSSFUnmarshaller.java:115)
at com.poiji.bind.mapping.XSSFUnmarshaller.unmarshal0(XSSFUnmarshaller.java:86)
at com.poiji.bind.mapping.XSSFUnmarshallerFile.returnFromExcelFile(XSSFUnmarshallerFile.java:43)
at com.poiji.bind.mapping.XSSFUnmarshallerFile.unmarshal(XSSFUnmarshallerFile.java:35)
at com.poiji.bind.Poiji.fromExcel(Poiji.java:303)
at com.poiji.bind.Poiji.fromExcel(Poiji.java:279)
at com.example.readModel(ReadService.java:314)
Beta Was this translation helpful? Give feedback.
All reactions