JAVA annotationÈëÃÅ
JAVA annotationÈëÃÅ
×î½ü¶ÔspringÔ´Âë¸ÐÐËȤ£¬½ñÌì¿´µ½annotation²¿·Ö£¬ÂÔ¼ÇÖ®¡£
Ò». ×î³£¼ûµÄannotation
@Override:ÓÃÔÚ·½·¨Ö®ÉÏ£¬ÓÃÀ´¸æËß±ðÈËÕâÒ»¸ö·½·¨ÊǸÄд¸¸ÀàµÄ
@Deprecated:½¨Òé±ðÈ˲»ÒªÊ¹ÓþɵÄAPIµÄʱºòÓõÄ,±àÒëµÄʱºò»áÓòúÉú¾¯¸æÐÅÏ¢,¿ÉÒÔÉ趨ÔÚ³ÌÐòÀïµÄËùÓеÄÔªËØÉÏ.
@SuppressWarnings:ÔÝʱ°ÑһЩ¾¯¸æÐÅÏ¢ÏûÏ¢¹Ø±Õ
@Entity:±íʾ¸ÃÀàÊǿɳ־û¯µÄÀà
¶þ. Éè¼ÆÒ»¸ö×Ô¼ºµÄAnnotation
ÏÈ¿´´úÂëÔÙ½²»°
1. Ö»ÓÐÒ»¸ö²ÎÊýµÄAnnotationʵÏÖ
package chb.test.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MyAnnotation1 {
String value();
}
2. ÓÐÁ½¸ö²ÎÊýµÄAnnotationʵÏÖ
package chb.test.annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface MyAnnotation2 {
String description();
boolean isAnnotation();
}
3. AnnotationʵÑéÀà
package chb.test.annotation;
@MyAnnotation1("this is annotation1")
public class AnnotationDemo {
@MyAnnotation2(description="this is annotation2",isAnnotation=true)
public void sayHello(){
System.out.println("hello world!");
}
}
4.Annotation²âÊÔ˵Ã÷Àà
package chb.test.annotation;
import java.lang.reflect.Method;
import org.junit.Test;
public class TestAnnotation {
@Test
public void test() throws ClassNotFoundException, SecurityException, NoSuchMethodException{
Clas
Ïà¹ØÎĵµ£º
Ò»ÖøÃûÈí¼þ¹«Ë¾µÄjava±ÊÊÔËã·¨Ì⣡(2008-11-06 12:49:19)±êÇ©£ºjava ÃæÊÔÌâ it ·ÖÀࣺJ2SE
ÔÌâÈçÏ£ºÓÃ1¡¢2¡¢2¡¢3¡¢4¡¢5ÕâÁù¸öÊý×Ö£¬ÓÃjavaдһ¸ömainº¯Êý£¬´òÓ¡³öËùÓв»Í¬µÄÅÅÁУ¬È磺512234¡¢412345µÈ£¬ÒªÇó£º "4 "²»ÄÜÔÚµÚÈý룬 "3 "Óë "5 "²»ÄÜÏàÁ¬.
ÎÒ¿´ÁË»ØÌù¶¼Ã»Óкܺýâ¾ö£¬Ö÷ÒªÊÇûÓÐÅųýÖ ......
ÔÎĵØÖ·:
http://blog.csdn.net/luozhenyu/archive/2008/11/07/3247740.aspx
×î½üµÄÒ»¸öÏîÄ¿£¬²ÉÓÃJSP+Servlet¿ª·¢µÄWebÓ¦Ó㬹¦Äܲ»¸´ÔÓ£¬Éæ¼°µ½Ò»Ð©¶àÏ̴߳¦Àí¼°ÍøÂç±à³Ì¡£²âÊÔÆڼ䷢ÏÖÔÚ»áÔì³ÉϵͳʱÖÓ±ä¿ì£¬»ù±¾ÔËÐв»µ½Ò»Ð¡Ê±¾Í¿ìÁË10À´·ÖÖÓ£¬¿ª³öʱÖÓ³ÌÐòÄÜÃ÷ÏԸоõÃëÖÓÌø¶¯±È½Ï¿ì¡£¼ì²é¹ý´úÂëûÓÐÓõ½ÈκÎÓйØʱ¼ ......
JavaÓïÑÔ·´ÉäÌṩһÖÖ¶¯Ì¬Á´½Ó³ÌÐò×é¼þµÄ¶à¹¦ÄÜ·½·¨¡£ËüÔÊÐí³ÌÐò´´½¨ºÍ¿ØÖÆÈκÎÀàµÄ¶ÔÏó(¸ù¾Ý°²È«ÐÔÏÞÖÆ)£¬ÎÞÐèÌáÇ°Ó²±àÂëÄ¿±êÀà¡£ÕâЩÌØÐÔʹµÃ·´ÉäÌرðÊÊÓÃÓÚ´´½¨ÒԷdz£ÆÕͨµÄ·½Ê½Óë¶ÔÏóÐ×÷µÄ¿â¡£ÀýÈ磬·´Éä¾³£ÔÚ³ÖÐø´æ´¢¶ÔÏóΪÊý¾Ý¿â¡¢XML»òÆäËüÍⲿ¸ñʽµÄ¿ò¼ÜÖÐʹÓá£Java reflection ·Ç³£ ......
ż¶ûÔÚÍøÉÏ·¢ÏÖµÄһƬ¹ØÓÚÕÆÎÕJAVAµÄ±ê×¼£¬¸Ð¾õÓеãÒâ˼£¬ËäÈ»ÔÚһЩ¹ÛµãÉÏÓÐЩƫÆÄ£¬µ«×÷ΪѧϰJAVAµÄÒýµ¼Éпɡ£ÖÁÓÚÔ´´ÊÇËûÓбØÒª¿¼Ö¤¡£
ʱ³£¿´µ½Ò»Ð©ÈË˵ÕÆÎÕÁËJava£¬µ«ÊÇÈÃËûÃÇÓÃJava×öÒ»¸öʵ¼ÊµÄÏîÄ¿¿ÉÄÜÓÖÀ§ÄÑÖØÖØ£¬ÔÚÕâÀ±ÊÕ߸ù¾Ý×Ô¼ºµÄÒ»µãÀí½â¶·µ¨Ìá³ö×Ô¼ºµÄһЩ¶ÔÕÆÎÕJavaÕâ¸ö˵·¨µÄ±ê×¼£¬µ±È»¶ÔÓÚР......
Javaѧϰ´ÓÈëÃŵ½¾«Í¨
Ò»¡¢ JDK (Java Development Kit)
JDKÊÇÕû¸öJavaµÄºËÐÄ£¬°üÀ¨ÁËJavaÔËÐл·¾³£¨Java Runtime Envirnment£©£¬Ò»¶ÑJava¹¤¾ßºÍJava»ù´¡µÄÀà¿â(rt.jar)¡£²»ÂÛʲôJavaÓ¦Ó÷þÎñÆ÷ʵÖʶ¼ÊÇÄÚÖÃÁËij¸ö°æ±¾µÄJDK¡£Òò´ËÕÆÎÕJDKÊÇѧºÃJavaµÄµÚÒ»²½¡£×îÖ÷Á÷µÄJ ......