Saturday, 2 September 2017

How to create a Spring applicaiton ?




CREATING SPRING EXAMPLE


PreRequisites
  • Download Spring Jars and Apache Logging Jars
  • In eclipse, New > Java project
  • Properties > Java build path > Add Lib / Jars
    • Choose {downloaded package}/dist/*.jar
    • Choose Commons-logging-*.jar
Code
public class DrawingApp {
  p.s.v. main(String[] args) {
    // Triangle t = new Triangle();
    BeanFactory factory = new XmlBeanFactory(new   

    FileSystemResource("spring.xml"));
    Triangle t = (Triangle) factory.getBean("triange");
    t.draw();
  }
}
public class Triangle {
  public void draw() {
    s.o.p("Draw the Triangle");
  }
}

 spring.xml - Use code from a sample ApplicationContext.xml
<beans>
   <bean id="triangle" class="com.shaan.exmaple.Triangle" />
</beans>



No comments:

Post a Comment

Note: only a member of this blog may post a comment.