Skip to content

Instantly share code, notes, and snippets.

@darbyluv2code
Created July 10, 2017 14:41
Show Gist options
  • Select an option

  • Save darbyluv2code/3a1e7fc55af756f743dee9e6de5d690d to your computer and use it in GitHub Desktop.

Select an option

Save darbyluv2code/3a1e7fc55af756f743dee9e6de5d690d to your computer and use it in GitHub Desktop.
spring starter
<?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="com.training.springdemo.FootballCoach">
</bean>
</beans>
package com.training.springdemo;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class HelloSpring {
public static void main(String args[]){
//load the spring configuration file
ClassPathXmlApplicationContext context =
new ClassPathXmlApplicationContext("applicationContext.xml");
//retrieve bean from spring container
Coach theCoach = context.getBean("myCoach", Coach.class);
//call methods on the bean
System.out.println(theCoach.getDailyWorkout());
//close the context
context.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment