Spring annotation (all jars used by spring)

Source: Internet
Author: User

We need four things.

1 Jar 2 Default construction method 3bean.xml add the corresponding statement 4@resource

1 The spring jar packages that are used are listed below


Aspectjrt.jar Aspectweaver.jar Cglib-nodep-2.1_3.jar

Common-annotation.jar Commons-logging.jar

Spring.jar


If you use the JDBC

Also use two jar files

Commons-dbcp.jar

Commons-pool.jar

Mysql-connector-java-5.1.18-bin.jar

Cn.dao [Java] view plain copy <pre name= "code" class= "Java" >package Cn.dao;      Public interface Persondaointerface {public abstract void add (); }

Cn.dao.imp

[Java] view plain copy package cn.dao.imp;      Import Cn.dao.PersonDaoInterface; public class Persondao implements Persondaointerface {public void Add () {System.out.println ("execute per       Sondao.add () "); }} Cn.service

[Java] view plain copy package cn.service;      Public interface Personservice {public abstract void Save (); } cn.service.imp

Package cn.service.imp;



Import Javax.annotation.Resource;

Import Org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor;

Import Cn.dao.imp.PersonDao;
Import Cn.service.PersonService;

public class Personservicebean implements Personservice {
	
	private String name;
	@Resource private Persondao Persondao;
	
	Public Personservicebean () {} public
	
	Personservicebean (String Name,persondao persondao) {
		this.name = name;
		This.persondao=persondao;
	}

	Public String GetName () {return
		name;
	}

	public void SetName (String name) {
		this.name = name;
	}

	Public Persondao Getpersondao () {return
		Persondao;
	}

	public void Setpersondao (Persondao persondao) {
		This.persondao = Persondao;
	}

	public void Save ()
	{
		persondao.add ();
		SYSTEM.OUT.PRINTLN (name);
		
	}



Juintest

[Java]   View plain copy package junit.test;      import  org.junit.test;   import org.springframework.context.applicationcontext;   import  org.springframework.context.support.abstractapplicationcontext;   import  org.springframework.context.support.classpathxmlapplicationcontext;      import  cn.service.imp.personservicebean;         public class springtest     {        @Test         public 

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.