You need to specify the path:
... ClassPathXmlApplicationContext("classpath*:com/acc/resources/applicationContext.xml");
Pergunta
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/
?
Solução
You need to specify the path:
... ClassPathXmlApplicationContext("classpath*:com/acc/resources/applicationContext.xml");