Frage

I am having some trouble with NoSuchBeanDefinitionException...

Here is my class :

package fr.aaaa;
@Component
public class Computation {
    static Logger logger = Logger.getLogger(Computation.class);

    public Computation() {
    }

    public static void main(String[] args) {
        ApplicationContext context = new ClassPathXmlApplicationContext("classpath*:applicationContext.xml");
        Computation computer = context.getBean(Computation.class);
    }
}

my applicationContext.xml file was located in src/main/resources/com/acc/resources/. I copied it in src/main/resources/ and no more exception were raised.

How can I change the classpath in order for Spring to find the xml file in src/main/resources/com/acc/resources/ ?

War es hilfreich?

Lösung

You need to specify the path:

... ClassPathXmlApplicationContext("classpath*:com/acc/resources/applicationContext.xml");
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top