Announcement Announcement Module
No announcement yet.
JavaConfig migration to Spring 3 Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • JavaConfig migration to Spring 3

    Hi to all:
    I'm trying to migrate and old project that uses Spring 2+JavaConfig 1.0.0.m3 to Spring 3. It's an application inside a Red5 server (migrating from 0.6 to 1.0RC). After solving several issues I'm totally stucked now. I've sucessfully migrated the annotations but I think that the old behaviour is different from the actual one.

    First of all, I'm not the one that created the old version, so my comments might not be totally accurate. In the old version in my opinion every method annotated with @Bean was called and therefore the bean was created. In the migrated version the behaviour seems to be different, and no method is called. My class is annotated as @Configuration for example:

    public class InMemoryNodeRepositoryConfig
    	private static final String NET_FILE_NAME = "net.xml";
    	public InMemoryNodeRepositoryConfig()
    		System.out.println("Constructor called");
    	public NodeRepository nodeRepository(final Settings systemSettings) throws Exception
    		System.out.println("Bean created");		
    		final File cfgDir = Files.getConfDir(systemSettings);
    		final String thisNodeId = systemSettings.getString(Settings.NODE_ID_KEY);
    		final File netFile = new File(cfgDir, NET_FILE_NAME); 
    		return XmlNodeRepositoryLoader.load(thisNodeId, netFile);
    The constructor is called (it's included in an xml as a bean) but the method nodeRepository it is not. Do I need any extra annotation? Is there something that I'm not understanding?

    Thanks in advance

  • #2
    Make sure you have <context:annotation-config/> declared in your XML. This enables processing of @Configuration classes.


    • #3
      Thank you so much!!, now at least is crashing but in the object creation...