修訂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