Question

My application loads Spring bean definitions from two XML files:

String[] beandefs = new String[] {
        "commonConfig.xml",
        "specificConfig.xml"
  };
  ApplicationContext context = new ClassPathXmlApplicationContext(
        beandefs);

This is because commonConfig.xml contains definitions that I want in all deployments. specificConfig.xml has definitions which I swap out for other implementations in a test deployments.

This works fine, except that where a bean references another bean in the other file, Eclipse (STS) marks it with a warning.

e.g. If commonConfig.xml contains:

  <bean id="foo" class="com.example.Foo">
    <property name="bar" ref="bar" />
  </bean>

... and specificConfig.xml contains:

  <bean id="bar" class="com.example.Bar">
       ...
  </bean>

The application works fine, but Eclipse warns in commonConfig.xml:

 Referenced bean 'bar' not found.

How can I tell Eclipse to look in both files?

Was it helpful?

Solution

Yes: you have to open the "Beans" element in the "Spring Explorer" view, there you can configure the different files that should be loaded (Tab "configFiles") and in Tab "config Sets" you can create a new Config Set and define the xmls that belongs to this context.

enter image description here

OTHER TIPS

Yes all you do is create a "config set". To locate it go to the project properties. Then collapse "Spring" and select "Bean Support". One of the tabs is "Config Sets".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top