With SSM projects, many Service,dao are defined using annotations, and ordinary Java classes get to these beans, which can be written like this: Public class Common { private userservice userservice; Public Common () { @SuppressWarnings ("resource") abstractapplicationcontext ctx New Classpathxmlapplicationcontext (new String []{"Classpath:spring-mvc.xml", "Classpath: Spring-mybatis.xml "}); = (UserServ
Create Class Personbean, with Properties Name,age and MN, to generate get and set methodsMain methodMap2bean Method:Bean2map Method:Test results:Summary: JavaBean and map introspector) and reflection (reflect) mechanisms. The idea is to get the BeanInfo information of an object through the class Introspector, then get the descriptor PropertyDescriptor of the property by BeanInfo, and then use the property descriptor to get the getter/of a property. Setter method, and then through the reflection
The purpose of this blog: ① summary of their own learning process, equivalent to study notes ② to share their own experience to everyone, learn from each other, communication, not commercialcontent inevitably appear problems, welcome to correct, exchange, discussion, you can leave a message, can also be contacted by the following ways. I Internet technology enthusiasts, Internet technology enthusiastsWeibo: Ivan is in 0221qq:951226918--------------------------------------------------------------
This article provides a detailed analysis of how to obtain the bean configured in Spring in Java. For more information, see
1. What is Spring?Spring is a lightweight container framework for IoC and AOP.
2. How can I obtain Spring-configured beans in a program?Method 1: Save the ApplicationContext object during initializationCode:
Copy codeThe Code is as follows:
ApplicationContext ac = new FileSystemXmlAppl
folder.3.2 Configuring the Application Server Xdoclet (optional)Xdoclet is able to generate server-specific deployment descriptors.Note: you will see later the steps for deploying FIRSTEJB to the local JBoss server, which use the JBoss subtasks.1. Right-click FIRSTEJB, select Properties, expand MyEclipse, and then select Xdoclet.2. Select the standard EJB to view the task, right-click Ejbdoclet, and select Add.3. Select JBoss, then click OK.4. Select JBoss subtask, double-click the Destdir prop
Package Ctgu.java;//import Java.sql.date;//import Java.util.list;//import java.util.arraylist;//importJava.util.date;//import java.util.scanner;import Static Java.lang.system.*;import Java.lang.reflect.field;import java.util.*;p Ublic class Testpackageimport {public static void main (string[] args) {out.println ("HelloWorld"); Scanner s = new Scanner (system.in), S.next ();D ate d = new Date (); List List = new ArrayList (); java.sql.Date D1 = new Java.sql.Date (5222222l); Field f = null;}}
1 ImportJava.util.*;2 3 Public classslots6_21 {4 Final Static intDEPTH = 10;5 6 Public Static voidMain (string[] args) {7Scanner input =NewScanner (system.in);8 9System.out.print ("Enter The number of beans:");Ten intBeans =input.nextint (); One A simulate (beans); - - } the - - Public Static voidSimulate (intN) { - + //The result array of the last layer, Slots[i] indicates the number of beans in i+1 position - + int[] Slots =New i
This article is a detailed analysis of how to obtain the beans in spring in Java, the need for a friend reference under
One, what is spring?Spring is a lightweight, control reversal (IoC) and aspect-oriented (AOP) container framework
How do I get a spring-configured bean in a program? Method One: Save the ApplicationContext object when initializingCode:
Copy Code code as follows:
ApplicationContext a
Java Test class Gets the spring Bean methodhttp://blog.163.com/lizhenming_2008/blog/static/76558333201362094243911/1. Through the spring contextApplicationContext ctx = new Classpathxmlapplicationcontext ("Applicationcontext.xml");DataSource ds = (DataSource) ctx.getbean ("DataSource");2, Resource classResource rs = new Filesystemresource ("**/**/appliactioncontext.xml");Beanfactory factory = new Xmlbeanfac
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.