Question:
When can a Vaadin bean be in a spring container ( @SpringComponent annotation)?
Clarification of the issue:
I ask this question because I know that Vaadin View can be spring bean after using @SpringView . But if I comment on the Button component with @SpringComponent , it will be created only once. Could this be a problem?
Example:
I have a lot of JpaRepository bean:
public interface CustomerRepository extends JpaRepository<Customer, Long> // ... public interface UserRepository extends JpaRepository<User, Long> {
And I want to use them in different places - for example, in the Tab component (in Vaadin TabSheet). So I have an idea - tabContent could also be a spring component:
@SpringView(name = "viewName") public class SomeView extends VerticalLayout implements View { @Autowired private SomeTabContent tabContent;
And then I can enter all the necessary beans:
@SpringComponent public class SomeTabContent extends VerticalLayout { @Autowired private CustomerRepository customerRepository; @Autowired private UserRepository UserRepository; }
Is this the right architecture?
Note. I know that Vaadin has CDI and Data Binding features, but I don't want to use them. I also know that I could manually create the spring application context anywhere, but I think this is not correct.
source share