Build and test the spring Development Environment

Source: Internet
Author: User
Build and test the spring Development Environment

1. Import the class library
\ Dist \ spring. Jar
\ Lib \ Jakarta-commons \ commons-logging.jar
If you use aspect Programming AOP, you also need to import the following:
\ Lib \ aspectj
Aspectjrt. Jar
Aspectjweaver. Jar
If you use annotations in the jsr-250, such as @ resource/@ postconstruct/@ predestroy, you also need the following JAR files:
\ Lib \ J2EE \ common-annotations.jar

2. Beans. xml

<? XML
Version ="1.0"
Encoding =UTF-8"?>

<Beans
Xmlns =Http://www.springframework.org/schema/beans"

Xmlns: xsi =Http://www.w3.org/2001/XMLSchema-instance"

Xsi: schemalocation =Http://www.springframework.org/schema/beans

Http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

<Bean
Id ="Personservice"
Class ="Cn. Kevin. Service. impl. personservicebean"> </Bean>

</Beans>

3. personservice. Java

PackageCN. Kevin. Service;

 

Public
Interface
Personservice {

 

Public
Abstract void
Save ();

 

}

4. personservicebean. Java

PackageCN. Kevin. Service. impl;

 

ImportCN. Kevin. Service. personservice;

 

Public
Class
Personservicebean
Implements
Personservice {

Public
Void
Save (){

System.Out. Println ("I am the Save method ..");

}

}

5. Test. Java

@ Test

Public
Void
Test (){

Applicationcontext CTX =NewClasspathxmlapplicationcontext ("Beans. xml ");

Personservice personserivce = (personservice) CTX. getbean ("personservice ");

Personserivce. Save ();

}

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.