Issue
I am new to springboot, I changed the class to 'springboot.practice.Coach' and still got an error.
Here is my applicationContext.xml code
<?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:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd">
<bean id="myCoach"
class="springboot.practice.MyApp">
</bean>
</beans>
here is the main class package springboot.practice;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class SpringHello
{
public static void main(String[] args)
{
ClassPathXmlApplicationContext context = new
ClassPathXmlApplicationContext("applicationContext.xml");
Coach theCoach = context.getBean("myCoach", Coach.class);
System.out.println(theCoach.getDailyWorkout());
context.close();
System.out.println("dasdsadas");
}
}
Im stuck here for almost 3 hours.
Solution
When you add this to your configuration:
<bean id="myCoach" class="springboot.practice.MyApp">
You are instructing spring IoC container to expect bean of class MyApp, Change this class to springboot.practice.Coach (ot correct classpath) and it should be resolved.
Answered By - Mihael Mihov
Answer Checked By - Willingham (JavaFixing Volunteer)