修订JavaConfig问题的Web应用程序(Vaadin +春季)
我发现了一个可疑的日志条目:
org.springframework.beans.factory.wiring.BeanConfigurerSupport:
BeanFactory has not been set on BeanConfigurerSupport: Make sure this configurer runs in a Spring container.
Unable to configure bean of type [com.mycompany.projectname.App]. Proceeding without injection.
/更新
我工作的一个Vaadin + Spring应用程序,我希望使用JavaConfig。
据一些教程,我建起来分开,但是当我将它们合并,我得到了如下(见第一codesnipet App.java - logger.info(“>>主窗口为空”);)
app postconstruct ---------
mainWindow is null
我尝试了几个变体的配置,例如在applicationContext等等。
所以我的问题是:我怎么才能找到真正的问题?
感谢您的时间和精力提前。
乔鲍
App.java
@Configurable
public class App extends Application
{
public MainWindow mainWindow;
public MainWindow getMainWindow(...
public void setMainWindow(Main....
@PostConstruct
public void init()
{
logger.info(">>app postconstruct --------- ");
if(mainWindow==null) logger.info(">>mainWindow is null");
else logger.info(">>mainWindow is not null");
}
AppConfig.java
@Configuration
public class AppConfig {
...
@Bean
public MainWindow mainWindow(){
return new MainWindow();
}
....
}
的web.xml在此基础上!tutorial link!
...
<context-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</context-param>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>com.mycompany.projectname.config.AppConfig</param-value>
</context-param>
...
<servlet>
<servlet-name>Vaadin Application Servlet</servlet-name>
<servlet-class>com.vaadin.terminal.gwt.server.ApplicationServlet</servlet-class>
<init-param>
<description>Vaadin application class to start</description>
<param-name>application</param-name>
<param-value>com.mycompany.projectname.App</param-value>
</init-param>
<init-param>
<param-name>contextClass</param-name>
<param-value>
org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>com.mycompany.projectname.config.AppConfig</param-value>
</init-param>
</servlet>
你好,** 1。**我跟着一个教程,使得Vaadin应用程序类成为Spring容器。所以应用程序类关注于Vaadin和Spring之间的联系。而这个类是由atConfigurable注释的,这就是为什么我不敢去除:) ** 2。**我根据spring doc [link](http://goo.gl/qlpQf)做了一个测试项目, atComponent没有注释类,尽管在那里使用了组件扫描。另外,测试项目不需要atComponent注解[pic](http://img684.imageshack.us/img684/4163/image000m.png)。 – cscsaba
虽然在尝试多次尝试使用atComponent注解之后,类必须连线。但它没有奏效。很明显我做错了。我接受你的话,并感谢你的建议。 – cscsaba
(我的javaconfig测试用例中的一个类[link](http://test-workbench.googlecode.com/svn/projects/vs2/tags/0/src/main/java/com/mycompany/MavenVaadinSpring/service /UserManagerImpl.java)) – cscsaba