Colleagues, I am confused to place the Vaadin Upload component inside the Spring component. Source code below:
------------------------------------------------------------------
@Route
@PWA(name = "Project Base for Vaadin Flow with Spring", shortName = "Project Base")
public class MainView extends VerticalLayout {
public MainView(Uploader uploader) {
add(uploader);
}
}
@Component
class Uploader extends HorizontalLayout {
private final Upload upload;
public Uploader() {
MemoryBuffer buffer = new MemoryBuffer();
upload = new Upload(buffer);
add(upload);
}
}
------------------------------------------------------------------
В этом случае летит ошибка:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'uploader' defined in file
[/home/chernov/work/secutity/target/classes/ru/mobilcard/cvr/spring/Uploader.class]: Instantiation of bean failed;
Однако код, приведенный ниже прекрасно работает:
public class MainView extends VerticalLayout {
public MainView() {
add(new Uploader());
}
//@Component
class Uploader extends HorizontalLayout {
private final Upload upload;
public Uploader() {
MemoryBuffer buffer = new MemoryBuffer();
upload = new Upload(buffer);
add(upload);
}
}
}
------------------------------------------------------------------