English 中文(简体)
JavaConfig 网络应用问题(Vadin + Spring)
原标题:JavaConfig problem in web application (Vaadin + Spring)

我发现可疑的登录:

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.

UPDATED

I m从事Vadin + Spring申请工作,我希望使用JavaConfig。

According to some tutorial I built them up separately, but when I merge them I got the following (see the first codesnipet App.java - logger.info(">>mainWindow is null");)

app postconstruct --------- 
mainWindow is null

我尝试了几处混杂物,例如,在应用中。

www.un.org/Depts/DGACM/index_spanish.htm 因此,我的问题是:我如何能够找到真正的问题?

感谢你的时间和努力。

Csaba

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();
    }
    ....    
    }

网页:

...
<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>
最佳回答

Why are you using @Configurable? Do you mean to be using @Component instead?

@ 可溶解性通常用于不属于春季管理的物体的域物体(aka实体),以便从春季集装箱中接收依赖性注射。 这似乎不是你的目标。 你或许应该把“App”类作为另一种@Bean方法,或者用@Component加以标识,并通过部件扫描(例如与@ComponentScan)取而代之。 为这些说明查找相关的Javadoc和参考文件,以供参考。

问题回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签