도너와 CommonsMultipartFile에서 byte []로 매핑하려고합니다.NoClassDefFoundError : CommonsMultipartFile에서 byte []에 파일 매핑하기
나는 내가 customConverter 원인 도저는 CommonsMultipartFile 유형에 대해 아무것도 모르는 필요 알고, 그래서 내가 만든이 :
public class FileJtfConverter extends DozerConverter<CommonsMultipartFile, byte[]> {
/**
* Constructor
*/
public FileJtfConverter() {
super(CommonsMultipartFile.class, byte[].class);
}
@Override
public final byte[] convertTo(CommonsMultipartFile a, byte[] b) {
if (a != null) {
return a.getBytes();
}
return null;
}
@Override
public final CommonsMultipartFile convertFrom(byte[] b, CommonsMultipartFile a) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
그리고 내 도저 XML 파일 :
<mapping type="one-way">
<class-a>myPackage.ClassA
</class-a>
<class-b>myPackage.ClassB
</class-b>
...
<field custom-converter="es.xunta.formacion.sifo3.transporte.util.converter.FileJtfConverter">
<a>anexo</a>
<b>anexo</b>
</field>
</mapping>
경우 클래스 A와 B 클래스는 다음과 같습니다.
public class ClassA{
...
private CommonsMultipartFile anexo;
...
public final CommonsMultipartFile getAnexo() {
return anexo;
}
public final void setAnexo(CommonsMultipartFile anexo) {
this.anexo = anexo;
}
}
public class ClassB{
...
protected byte[] anexo;
...
public void setAnexo(byte[] value) {
this.anexo = ((byte[]) value);
}
public byte[] getAnexoPago() {
return anexoPago;
}
}
모두 괜찮아 보이지만 예외가 있습니다. org.dozer.MappingException : java.lang.NoClassDefFoundError가 : 조직/아파치/평민/파일 업로드/FileUploadException
그리고 내 pom.xml 파일의 종속성을 정의하기 때문에이 꽤 이상해 ...
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
</dependency>
어떤 아이디어 ..? 고마워요!
클래스 경로에 commons-fileupload를 추가하십시오. – bmargulies