Answer the question
In order to leave comments, you need to log in
ClassPathXml ApplicationContext?
public class HelloWorldSpringDI {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("src/resources/app-context.xml");
MessageRenderer mr = ctx.getBean("renderer", MessageRenderer.class);
mr.render();
}}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="provider"
class="HelloWorldМesProvider"/>
<bean id="renderer"
class="StandardOutMesRenderer"
p:messageProvider-ref="provider"/>
</beans>
Answer the question
In order to leave comments, you need to log in
Invalid path specified. What is in src is added to the classpath root. It should be like this:
public class HelloWorldSpringDI {
public static void main(String[] args) {
ApplicationContext ctx = new ClassPathXmlApplicationContext("resources/app-context.xml");
MessageRenderer mr = ctx.getBean("renderer", MessageRenderer.class);
mr.render();
}}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question