Spring Source Learning: 1th Step-Add the simplest demo code to spring source

Source: Internet
Author: User

In order to maximize the proximity of the spring source and learning, a more direct approach is: directly in the spring source code to add the demo, and debugging.

Referring to the previous experience with spring, Spring's simplest approach is to use an entity class, an XML configuration file, and a test method. For the use of out-of-source code, you need to introduce at least spring-context dependency. So, guess, in the spring source code can be directly in the Spring-context module to add the simplest of the above?

Just do it. In the Spring-context module, create a new entity class (person, under the COM.CYH package), an XML configuration file (Person.xml), and a simple test method (Persontest) with the following structure:

As for the content, it's even easier:

    1. The content in person is empty (because spring only needs to be a simple Pojo)
    2. Person.xml file, one line configuration (simplest bean configuration, e.g.)
    3. Persontest also reads the configuration file directly from the Classpathxmlapplicationcontext, then gets the configured bean and then simply prints

Everything is OK, the console smoothly prints out the following content:

Person.getclass (). GetName (): Com.cyh.Person

The simplest demo code, added to the spring source and successfully run, done ~

Offer yourself a fork from GitHub and "trample" the Spring Source address: Https://github.com/cyhbyw/spring-framework/tree/Branch_v4.2.5.RELEASE

Spring Source Learning: 1th Step-Add the simplest demo code to spring source

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.