Spring Source Code research-download-compile-import eclipse-verify, springeclipse-

Source: Internet
Author: User

Spring Source Code research-download-compile-import eclipse-verify, springeclipse-

I. Environment Configuration

Operating System: Unbutu14.04LTS

JDK: 1.8.0 _ 40

Git: 1.9.1

Gradle: 2.2.1

2. Download the source code-compile-import eclipse-verify

1. Download

Use git to directly clone the Spring source code to the local machine: git clone git: // github.com/SpringSource/spring-framework.git

2. Compile

During the compilation process, the so-called compilation is to use the gradle tool to compile the Spring-framework project file. The main task is to download the jar packages that Spring modules depend on, this process is generally very slow, probably because the resources are all in the pipeline and the jar package cannot be downloaded for a long time. At this time, press ctrl + c to exit the compilation command and execute the command again, the downloaded package will not be downloaded again, so the compilation process is equivalent to reconnection.

① Go to the source code directory and execute: gradle eclipse-x: eclipse (it took me one morning to compile and pass)

② I still don't know the specific role of executing gradle install, but if I don't execute this command to import the compiled code into eclipse, there will be a bunch of build path errors, we assume that the dependencies down in step 1 are stored in the gradle local repository to facilitate project search and use of related dependencies.

③ Import the source code directory of Spring-framework directly through eclipse

Groovy may not be found in this project. The main reason is that your eclipse does not have the Groovy plug-in installed. After installation, the clean Project will be OK.

④ Verification

Write a simple test project, simple IoC call function, and dependency on the spring-context Project

a),TestSpring.java
 1 import org.springframework.context.ApplicationContext; 2 import org.springframework.context.support.ClassPathXmlApplicationContext; 3  4 import com.test.bean.Lover; 5  6  7 public class TestSpring { 8     /** 9      * @param args10      */11     @SuppressWarnings("resource")12     public static void main(String[] args) {13         ApplicationContext ctx = new ClassPathXmlApplicationContext("bean.xml");14         Lover p = ctx.getBean("lover",Lover.class);15         p.info();16     }17 18 }

B), Lover. java

 1 package com.test.bean; 2  3 public class Lover { 4      5     private String name; 6     private int age; 7      8     public String getName() { 9         return name;10     }11     public void setName(String name) {12         this.name = name;13     }14     public int getAge() {15         return age;16     }17     public void setAge(int age) {18         this.age = age;19     }20     public void info(){21         System.out.println("Spring is a best lover fro you~~~");22     }23 }

C), bean. xml

 1 <?xml version="1.0" encoding="UTF-8"?> 2 <beans 3  xmlns="http://www.springframework.org/schema/beans" 4  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 5  xmlns:context="http://www.springframework.org/schema/context" 6  xsi:schemaLocation="http://www.springframework.org/schema/beans  7                     http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 8                     http://www.springframework.org/schema/context 9                     http://www.springframework.org/schema/context/spring-context-2.5.xsd10                     ">11                     12 <bean id="lover" class="com.test.bean.Lover" scope="prototype"></bean>13 14 </beans>

Iii. Summary

This article mainly summarizes the Spring source code download (github), compilation (gradle), the process of importing eclipse, and finally a simple test of the SpringIoC module function after eclipse is imported. From then on, we started a deep study of Spring source code.

 

This article is copyrighted. For more information, see the source.

Related Article

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.