Created
July 10, 2017 14:41
-
-
Save darbyluv2code/3a1e7fc55af756f743dee9e6de5d690d to your computer and use it in GitHub Desktop.
spring starter
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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