Create a new spring project from Eclipse

Source: Internet
Author: User
Tags apc

One: quasi-work (download the required jar package)

1. Download Preparation spring-framework-4.2.0

Links to:

http://repo.springsource.org/libs-release-local/org/springframework/spring/

  

2. Specific spring-framework4.2.0

  

3. Download Log

Links to:

http://commons.apache.org/proper/commons-logging/download_logging.cgi

  

Two: Construction projects

1. Create a common Java project

  

2. Create a new Lib folder and copy and paste the jar package into

  

3. BUiD the Lib package to path

  

Then import the required jar from the firstspring

Then reply and OK

  

4. The effect at this time

  

5. New Package

Class Package:

  

XML Package

  

6. New Class

First interface

1  Package Main.java.com.sommer.learn; 2 3  Public Interface HelloWorld {4      Public  5 }

Implementation class

1  Package Main.java.com.sommer.learn; 2 3  Public class Implements helloworld{4    @Override5public       String sayhi () {  6         return "Hahahahahha"; 7     }89 }

7. Create a new XML file

1 <?xml version= "1.0" encoding= "UTF-8"?>2 <beans3      xmlns= "/http/ Www.springframework.org/schema/beans "   4        xmlns:xsi=" Http://www.w3.org/2001/XMLSchema-instance "    5        6        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd ">7        8     class= "Main.java.com.sommer.learn.HelloWorldImpl" ></bean>9

8. New Main function

1  PackageMain.java.com.sommer.learn;2 ImportOrg.springframework.context.ApplicationContext;3 ImportOrg.springframework.context.support.ClassPathXmlApplicationContext;4 5  Public classMain {6      Public Static voidMain (string[] args) {7ApplicationContext APC =NewClasspathxmlapplicationcontext ("Springxml/helloworld.xml"); 8HelloWorld Hello = Apc.getbean ("HelloWorld", HelloWorld.class); 9 System.out.println (Hello.sayhi ()); Ten     }   One}

9. Running

  

  

Create a new spring project from Eclipse

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.