Spring boot 在Vaadin view Spring Boot中插入控制器
我使用Spring Boot和Vaadin为应用程序接口开发了一个应用程序web 我的问题是无法在控制器中查看,应用程序启动正常,但bean在执行时为空 我的控制器:Spring boot 在Vaadin view Spring Boot中插入控制器,spring-boot,vaadin7,vaadin4spring,Spring Boot,Vaadin7,Vaadin4spring,我使用Spring Boot和Vaadin为应用程序接口开发了一个应用程序web 我的问题是无法在控制器中查看,应用程序启动正常,但bean在执行时为空 我的控制器: @Component public class ViewController { /** Inyección de Spring para poder acceder a la capa de datos.*/ @Autowired private CommonSetup commonSetup; /** * This me
@Component
public class ViewController {
/** Inyección de Spring para poder acceder a la capa de datos.*/
@Autowired
private CommonSetup commonSetup;
/**
* This method gets the user from db.
*/
public Temployee getUser(String username, String password) {
Temployee empl = null;
// get from db the user
empl = commonSetup.getUserByUsernameAndPass(username, password);
// return the employee found.
return empl;
}
。。。
我的看法是:
@Theme("login")
@SpringUI
public class LoginView extends CustomComponent implements View ,Button.ClickListener {
/** The view controller. */
@Autowired
private ViewController vContr;
public LoginView() {
setSizeFull();
...
...
// Check if the username and the password are correct.
Temployee empleado = vContr.getUser(username, password);
在LoginView
中,bean视图控制器
为空
如何在视图中导入bean
谢谢。您无法访问构造函数中的自动连线字段,因为此时尚未完成注入。添加带有
@PostConstruct
注释的方法,该注释将在注入字段后执行:
@PostConstruct
public void init() {
// Check if the username and the password are correct.
Temployee empleado = vContr.getUser(username, password);
}
这不是vaadin4spring所特有的,这是Spring的工作原理